Monthly Archives: April 2013

Machine Speak: Why We Have Languages

When you tell a computer to do something, you are actually giving it a set on instructions. From the eyes of the CPU, these instructions cannot even be slightly ambiguous. As you may or may not know, computers use something called binary to store, transfer, and alter data.

What is binary? More than just a string of ones and zeros, binary represents fundamentally something either existing or not i.e. true or false. This system of counting is called base 2, it is much simpler than the counting system we use, base 10.  Here is a list of the first 10 numbers in binary.

  • 0 = 0000
  • 1 = 0001
  • 2 = 0010
  • 3 = 0011
  • 4 = 0100
  • 5 = 0101
  • 6 = 0110
  • 7 = 0111
  • 8 = 1000
  • 9 = 1001

In practical everyday use, a base two system has very little use. But to a computer, it is very useful, as it can easily assign value to anything using only two physical states, on or off. Obviously the base 10 system of counting is better to us, but is it really the best? Other types of counting systems include hexadecimal (base 16 counting system popular in memory chips), and there is even a small but growing group of people who believe counting in base 12 is the most advantageous.

Binary Clock

How a digital clock would look in binary. (Cr: wikipedia.org)

Assembly language the instructions to the computer, telling the processor where to put data or alter data. Unfortunately, this is very specific to each type of device, and extremely unreadable to people. When programmers write code, it obviously can not be in assembly because they would want it to work on more than one specific device. That is where the compiler comes in. A compiler, which is a type of program in itself, literally serves as a translator as it trans-codes a source language to an object language (think of the object language as the binary counterpart of the English based programming language).

Thanks for reading this weeks post on binary and assembly language, I hope you come back next week where I will discuss an extremely common programming language called C!

Unified Modeling Language

English: An UML Use case diagram.

A restaurant, shown by a type of UML. (Photo credit: Wikipedia)

As you can imagine, there are dozens and dozens languages that we can program in, and even though some are much more common than others, with a couple being extremely widespread in their use, it is never guaranteed that potential collaborators will have knowledge in the same types of code. More importantly, somebody with very little or no experience with actual programming still might want a way to communicate their ideas in a way that could be more easily implemented by a software engineer. This is where Unified Modeling Language (UML) comes in.

UML is the accepted way to model software in industry, it has a set of standards to help visualize the design of a project. To the average person, these specific standards are probably not important (Learn more!), but there are some basics to it that could be useful for everyone.  The goal is to visualize object oriented programming, meaning their is a well established hierarchy for the desired task.

To use a simple example, take a basic art program that uses different kinds of shapes. First of all to establish the hierarchy, we can declare that all shapes are indeed shapes, but think of how to distinguish rectangles from circles from squares or even lines. At the very top is shapes, on the second level is rectangles and circles, below the rectangles should be squares since they are only a type of rectangle. But how do we classify triangles? First you might think to add another type for them, but in reality triangles and rectangles are both polygons, introducing another parent shape into the diagram. As we can see decisions have to be made when designing UML, and while the best route to take is not always clear, it always pays off to have a clear plan ahead of time.

Thanks for reading and check back next week for a discussion on how the operating system and computer communicate!

Intro to Programming Languages

You might be asking yourself, “Why should I care about differences between programming languages or even how they work?” You might argue that it has no real use to your career/goals, but I would say that with the ever increasing reliance on computers in almost all occupations, everyone should know at least a little background information on how computers operate internally.

This blog will mainly serve as a guide to the practical applications of various programming languages, as well as delivering some basic background information on how they work. Today will serve as a simple introduction to computers and programming languages and what will come later in future blog posts.

A computer operates on the basic principle of giving an input (ultimately done by a user) and receiving a, hopefully correct, output.  What goes on in between, while unknown to most, is certainly not a mystery. The operating system (Windows 8 or OS X for example) orders tasks by importance to be sent to the physical computer, and cycles through them extremely quickly. This is the reason why computers are so useful, because of how fast they listen to and complete instructions.

Instructions to a computer are very difficult to write in a way humans can understand, as they are most likely done in binary, or strings of ones and zeros. This is where programming languages come in, it serves as a great way for us to communicate our instructions to the computer. While coding, it is extremely important to be very exact. If you were telling somebody how to create a peanut butter and jelly sandwich, you could very simply tell them to spread some jelly and peanut butter on their favorite type of bread. A computer would need much more specific directions i.e. first open the jar by turning the lid counter-clockwise, but what is counter-clockwise to a computer? This would also have to be defined, and as you see, could get quite complicated.

But what could be the benefit in detailing out these very fine instructions? Keeping this analogy, a computer would be able to create more sandwiches in an hour than you might ever dream of in your lifetime.