What is Source Code?

(and why you should know)

Source code is software, but not what most people think of as software.

You may think that software is the stuff that you see on the screen.  It works, right?  So why should you be concerned about how?

Because you do not own the software!

What you have purchased (for hundreds or thousands of dollars) in a shiny box with a manual and a CD is only a pile of ones and zeros.  What's even more disconcerting is that without the software, you cannot access your data.  You know:  the thousands of documents, drawings, and spreadsheets into which you have poured thousands of hours of effort.

Five or ten years from now, you may have completely lost the ability to open a file that you created today.

But, I paid for it, don't I own it?

The most that you actually own are the ones and zeros on the disc.  To make things worse, the license agreement limits what you can do with those ones and zeros.  But this is only a legal technicality.  The more frightening issue is simply a practical one: these ones and zeros are meaningless out of context!

A computer is a machine which essentially consists of a lot of on/off switches.

In order to make these switches do something useful, we have to plan out which switches to turn on in what order.  This is where the ones and zeros (bits) come in.  We call these "machine code" because they tell the machine which switches to turn on or off.  In very early and simple computers, the programmers would actually write their machine code by hand on paper and then toggle it into the switches on the front.

As software got more complicated, this machine code got longer and longer.  Today's software is constructed of billions of bits!

To make really complicated software, it is much more effective to write what we want to do in a high-level language (one that looks something like english) and then have a program (a compiler) translate this into machine code.

Source Code Machine Code (bits)
main () \{
  printf("hello world\n");
\}
111111100101000100001100100011000100
100000000100000000100000000000000000
000000000000000000000000000000000000
000000000000000000000000000000000000
010000000000000000110000000000000000
... (this goes on for thousands of lines)

While you may not completely understand the code on the left, only one kind of machine understands the code on the right.

Machines are Different

Some machines are wired differently than others, so if you try to feed machine code for one kind of computer (such as a PC) into another (like a Macintosh), you are telling the computer to flip the wrong switches.  To translate from one sort of machine code to the other is a practically impossible job because of the sheer number of bits involved.  Thus, if you want to "port" a program, you are going to need the source code.

As technology improves, computers are going to change.  When that happens, old machine code will be worthless.  Even if manufacturers make reverse-compatible machines, do you think they will still have all of the same switches a hundred years from now?

And Really Picky

It is impossible to change a program when all you have is the machine code.  Inserting a series of bits displaces everything that comes after it, so any attempt to modify machine code basically turns it into a bunch of garbage.

See if you can tell the difference between the two sets of 120 bits below.

111111100101000100001100100011000100
100000000100000000100000000000000000
000000000000000000000000000000000000
000000000000000000000000000000000000
010000000000000000110000000000000000
111111100101000100001100100011000100
100000010100000000100000000000000000
000000000000000000000000000000000000
000000000000000000000000000000000000
010000000000000000110000000000000000

Now just imagine swimming through 120 million bits!

With source code, a programmer can easily make changes and then have the compiler recreate correct machine code.

But I'm not a Programmer

This may be true, but if you want to hire one to modify a program, you would need the source code or even the best programmer in the world would be helpless.  If you hired a team of the world's most talented programmers and asked them to make a simple change to some program, they would have no choice but to rebuild the entire thing from the ground up if they didn't have the source.

So what should I do?

Use and insist on open-source software whenever you can.  For more information, see the other articles and links on this site.


All material Copyright © 2005-2009 Scratch Computing.