How to Think in Computer: Why They Do the Way They Do (Part 1)
Tags: beginners, computerscience, firstyearincode
Published: 2020-04-25 21:34:33

This article is for anyone who just started learning how to program and is struggling to get their brains wrapped around why computers do what they do. It is a guide to help you understand how a computer works and how to get it to do what you want.

Sound good? Awesome. Let's start with some Linguistics.

# The Sapir-Whorf Hypothesis

Language is way more powerful than we give it credit for. That's what Sapir and Whorf proposed in their theory of Linguistic Determinism: Your perception of the world is determined by the language you speak. That meaning, your view and idea of reality is limited to your vocabulary.

The neat thing about this theory is that it goes the both ways. *When you change your language, you change the way you perceive the world*. The more a physician learns about latin and its application to medical language, the more he will begin to perceive the world in a medical context.

You might see where I'm going with this. Computers speak a specific language, a language of numbers and algorithms. As you learn the syntax and semantics of programming, you'll begin to think in computer and approach problems with an algorithmic mindset.

If you start talking in Computer, you'll begin to understand it better.

But what exactly is the language?

# Mathematics: The Language of Computers

Yup. That's right. Computers use math, and lots of it. But why math? Couldn't we use something easier like Japanese or Arabic? Well, turns out computers are very ***very*** fast (like "count from 1 to a billion in less than a second" fast), but only at doing one thing in particular: computing. They are damn good at multiplying two stupidly big numbers together, but not so good at understanding why I cry while listening to Between the Bars (shut up, I know you do too).

Math is fine and dandy n' all, but not all of us are interested in solely adding numbers together all day. Thankfully a [badass](https://en.wikipedia.org/wiki/Alan_Turing) in history found a way to apply it to a [real world problem](https://en.wikipedia.org/wiki/Enigma_machine) which [helped saved us from the Nazis](http://www.iwm.org.uk/history/how-alan-turing-cracked-the-enigma-code). This man alone took computation into a whole new level and built an actual machine to 'compute' numbers as opposed to calculating them by hand; drastically increasing the speed at which we can perform computation.

Since then we've been finding new ways of representing information in a numeric and mathematical context. In short to say, everything you work with on a computer is some kind of representation of a number. Each pixel on your screen is some sort of color that corresponds to a set of numbers. That music you like to listen to (on a computer) is just a collection of numbers that are interpreted into various sounds. Even the letters of this article are just a string of numbers that the computer converts to text for you to read.

Computers are fast. Computers use only math and numbers. We convert information into math and numbers to use computers.

With me so far? Good. Let's keep going.

# Information: What We Use Computers For

If you think about it, computers do only one thing: handle information. Checking your bank account balance online? Getting Information. Sending a text message to your friend? Transmitting information. Deleting your browser history? Removing information. A good way to understand what a computer is doing, is to take step back and think in terms of what information is involved.

I could go into a whole other series explaining *why* we should care about how well we use information, but I'll try not to get too distracted here. Information is important because the advancement of human civilization coincides with how well we can share info with each other. Computers help that progression by providing an extremely efficient way of handling such information. We can see this by how technology evolves alongside the speed of computers. Given I understand it's not the only factor of societal advancement, but it is a very compelling one.

Everything computers do is some way to manipulate information. Information is important to society.

# But... Why are Computers so Complicated?

Computers at their fundamental level are actually quite simple. Technically you can compute any mathematical problem with only six operations, but we'll expand on that in the next article. For now, we can understand their complexity in this analogy:

Let's pretend you're the boss at a big company. You're in need of a secretary to handle the menial tasks while you work on the big decisions, so you ask your HR department for a reference and they give you Steve. Before sending him over, they mention two things about Steve: He is very specific, and he is *very* fast. You thank them, and before you hang up the phone you hear a knock on the door.

It's Steve. Huh, that was fast.

He enters and with a blank look on his face asks what he can do for you. You weren't expecting so quickly, but you manage to scramble up some forms that need to be filled out. You want to keep him busy, so you hand him a stack of about a hundred, show him how to fill each one out, and then send him on his way. 

You close your door and head back to your desk, but before you can sit down he knocks on the door. Thinking he might have a question you open up and there he is with a stack of completed forms in his hands. He can't be done, can he? Sure enough though, each and every form as been filled out exactly as you instructed him.

Wow, Steve is very fast.

Completely satisfied (albeit surprised) with his work you send him home for the day. You sit down to inspect the forms he completed, but then you realize a problem: you made a mistake and told Steve to fill out the wrong fields. You're about to call him back, but there's another knock on the door.

Could it be? Yup, it's Steve.

Confused as to why he's back, he tells you he did exactly what you told him to. He went home to sleep, but after napping for 2 months he felt it was time to get back to work. Stunned you stammer out something about the forms and which fields are incorrect. He nods, takes the forms to fill them out correctly.

While he's doing that it gives you a second to think. You begin to realize how much of an asset Steve is, how much work he could get done. However you remember the mistake he made and how careful you have'll to be so it doesn't happen again. Before you can start day dreaming about the company's potential, Steve opens the door and asks for his next task.

From here on, you begin to make a long list of things for Steve to do. You begin to realize that some tasks he's able to do quickly, while others take him a few minutes to get done. Overall he's so fast that instead of doing your normal work, you spend your day thinking of more complex things for Steve to do. Sometimes you make a mistake and have to give him instructions on how to fix it, and sometimes there are some tasks he simply can't do, but overall his work is very quick. Thanks to this efficiency, your company grows and you get to spend more time on your back swing than you do in the office.

***

As you can guess, Steve is a computer and the boss is you: a programmer. Steve isn't necessarily complicated, his complexity comes from taking advantage of his speed. Learning to code is partly about knowing how computers work, but mostly about the systems we've created to utilize the computer's efficiency. These systems are the field of study known as Computer Science.

Hopefully this article gives you basic idea of why computers do the way they do. In the next article, we'll talk more about the basic rules of computation and how you can approach getting a computer to work.