Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Created August 21, 2012 13:09
Show Gist options
  • Save EvanHahn/3415282 to your computer and use it in GitHub Desktop.
Save EvanHahn/3415282 to your computer and use it in GitHub Desktop.
Programming explained, draft 1

Let me teach you how programming works through the analogy of slavery.

Imagine that you had a slave. This slave had taken a bunch of your money and you struck a deal with him or her -- do my bidding and I will not throw you in jail.

You quickly learn that this slave isn't like the many other slaves you've had.

For one, this slave has terrible language skills. They only understands about 50 words and doesn't understand anything you say unless you say it very explicitly. If I ordered you, a non-idiot slave, to "bake me a cake", you'd do the same thing as if I said "bake a cake for me." Your slave is not this way: they only respond to "bake new cake for self."

Your slave also doesn't really know how to do anything. "Bake" means nothing to them. When your slave said "I don't understand," you rolled your eyes and said, "okay, start by getting the mix." Your slave said "I don't understand." After about an hour, you realized that your slave doesn't know how to get the mix! You had to instruct your slave to put one foot in front of the other foot, then move their hands up to the shelf and wrap their fingers around the mix. This felt ridiculous -- you had to break "bake a cake" into incredibly tiny instructions.

But there's something else interesting about this slave: the speed. The speed with which your slave works is unbelievable. It takes most people several minutes to bake a cake. Once you taught your slave how to bake a cake, it can bake an entire cake in a fraction of a second. You have to speak to it the right way, but when you do, it can bake over a thousand cakes in one second. Incredible!

This is exactly what computers are like. They're really dumb and you have to tell them very explicitly what to do, which can often be frustrating. Once you do, however, they become wildly powerful and can bake you thousands of cakes.

Programming is simply giving your computer orders. "Do this, do that."

You do this by speaking to it in what's called a programming language. Just like you can order your slave around in English or Spanish or Mandarin, you can order your computer around in different programming languages. Some examples of programming languages are JavaScript, C++, or Python. Each language does some things better than others (and some languages are just really bad, but we won't get into that). When you "speak a programming language", you "write code". I don't like to use the term "code" when talking to newbies because that makes it sound more daunting, but that is the accepted term.

Once you learn a couple of programming languages, most of the rest of them become easier. If you become a master of the Java programming language, then C++ won't be a huge jump. If you learn Python, you'll understand the syntax of the Ruby programming language. You won't be "fluent" -- programming languages can have accents, believe it or not -- but fluency is much easier to achieve than with a real, spoken language.

So, I guess the moral of this story is that programming is just like slavery!

by Evan Hahn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment