Why should you learn how to program? What is programming? What specific steps can you take? How can you apply programming?

To be a good programmer, it doesn’t take a lot of math. Instead, you need to be able to break larger ideas and processes like how to play tic-tac-toe into small steps. Imagine you were trying to explain tic-tac-toe to a small child. Then take a step back and imagine that you’re watching yourself explain this to a small child. Where do you begin? Be alert for all the steps.

You don’t just start putting X’s and O’s down on the paper. You first need to ask if the child wants to play. Then you can begin explaining the rules and eventually playing. There will usually be some parts you forgot about. What happens? The child will either ask or make a wrong move that you then have to explain. Maybe you forgot to mention that once you write a letter in a box, that it becomes unavailable for the other person to use. Seems obvious, right? Until the child draws an X on top of your O and claims victory.

Even such a simple game is much easier to explain to a child than to a computer. That’s because the child can draw conclusions based on other games and life experiences and naturally understand things without being told. You don’t have that luxury with a computer. No matter how old a computer gets, it never develops any common sense at all.

If you forgot to tell the computer about the same rule that you can’t make a move in a square that’s already occupied, then your game will likely crash. It’s a bug.

The ability to program then, really comes down to how good you can be about planning for all the possible ways something can go wrong and writing instructions to either make sure they don’t happen in the first place or how to handle each situation if they do.

The full episode explains more about programming and how you write the instructions that the computer will follow. Listen or read the full transcript below.

Transcript

The topic today is what is programming. Now, I already explained this in episode 2. I’ll try not to mention the same things and that early episode remains a good resource to help you understand programming.

I’ve talked with a lot of people about programming. People working in retail stores, attending seminars, selling products door-to-door, and others who ask me how to program. There’s a widely held belief that programming is hard and beyond their ability or doesn’t apply so why should they bother.

I’ve had people tell me that they could never program because they’re no good with math. Or they have goals to become a manager instead. Or they tried it once and didn’t get good grades. And some have said that they know how to program already and have built web pages.

I’m going to talk about these things while describing what is programming. I hope that you’ll realize that it’s not as hard as you thought and that it really is necessary. Listen to the previous episode for more discussion about why you should learn how to program.

First of all, you don’t need to know a lot of math in order to program. Unless, of course, you’re programming something that inherently uses math such as a library that calculates physics equations. That sort of thing just isn’t very common though. Even if you want to create a game that allows a player to launch annoyed avians through the air following a smooth arc, you might be surprised by just how little math you really need to know. Most of the time, all I really need to do is add or subtract things.

Let’s say you want to simulate a ball thrown up in the air, slowing down gradually, and then falling back down again. It should speed up as it falls. Does this require trigonometry, calculus, or some physics formulas where you have to remember the gravitational constant? No. All it takes is to add a little bit of velocity each time you update the ball’s position.

Surely, you’ll need to crack open your physics books to figure out how much to add, right? Nope. Just pick a value and try playing your game. If the ball moves too fast or too slow, then pick a different value. If you want to get really fancy, you can keep track of how much time has passed between each update and multiply that by the amount you’ll add to the velocity.

The point is that you can program very well with a basic grade school level understanding of math. This type of programming will allow you to build your own applications that run on your computer or embedded electronics if you’re into robotics.

I’ll talk about how programming can help you in part four of this series. I want to keep this episode focused on what is programming and so far, I’ve been rambling a bit. But let me explain a bit first about web pages.

Do you program a web page? A bit, yes. Especially the dynamic aspects of a web page. I mean the parts where action is involved. Maybe you want to hide or show sections based on choices made by the visitor. This does need a bit of programming usually in JavaScript. But if all you know is JavaScript, then I highly encourage you to learn more. Personally, I’m not a big fan of JavaScript. It’s easy because it lets you do almost anything but it also has a way of surprising you later. For simple tasks, it’s not a bad choice.

Computers are precise if nothing else and to me a good programming language is powerful enough to let you express your intentions without leaving it so open that you get confused when it gets more complicated.

Programming is nothing more than giving instructions to the computer so it knows what to do. That’s all really. But because computers have no ability to just do the right thing, they follow those instructions exactly. And very fast. You can’t just tell a computer to let the user play a fun game. You can’t even expect the computer to understand the rules for a simple game like tic-tac-toe.

To be a good programmer, it doesn’t take a lot of math. Instead, you need to be able to break larger ideas and processes like how to play tic-tac-toe into small steps. Imagine you were trying to explain tic-tac-toe to a small child. Then take a step back and imagine that you’re watching yourself explain this to a small child. Where do you begin? Be alert for all the steps. You don’t just start putting X’s and O’s down on the paper. You first need to ask if the child wants to play. Then you can begin explaining the rules and eventually playing. There will usually be some parts you forgot about. What happens? The child will either ask or make a wrong move that you then have to explain. Maybe you forgot to mention that once you write a letter in a box, that it becomes unavailable for the other person to use. Seems obvious, right? Until the child draws an X on top of your O and claims victory.

Even such a simple game is much easier to explain to a child than to a computer. That’s because the child can draw conclusions based on other games and life experiences and naturally understand things without being told. You don’t have that luxury with a computer. No matter how old a computer gets, it never develops any common sense at all.

If you forgot to tell the computer about the same rule that you can’t make a move in a square that’s already occupied, then your game will likely crash. It’s a bug.

The ability to program then, really comes down to how good you can be about planning for all the possible ways something can go wrong and writing instructions to either make sure they don’t happen in the first place or how to handle each situation if they do.

Once you understand this, you can build on it. Just like there’s usually multiple ways to accomplish something in real life, there’s usually multiple ways to accomplish something in programming. Some might be faster than others. Some might be simpler. Some might at first seem more complicated until you get to the end and realize that the extra complexity was there for a reason.

As you program, you’ll gain experience. You’ll develop a sense for when a simple solution is all that’s needed and when you need to spend more time to lay a stronger foundation.

I’ve explained the need to provide exact instructions that the computer will execute. But how do you provide these instructions. This is where programming languages come in. There are many languages and each was created for a specific reason or preference. Some languages are really good for working with text. Some are good for web pages. Some are good for writing the operating system of your computer itself. Some are good for creating games. And some best suited for financial applications.

All programming languages have one goal in mind. They allow you to write out the instructions that the computer will run at a later time in a format that you can understand and then provide a way to translate your written instructions into a format that the computer can understand. Remember, computers are really fast. So you can’t write instructions and expect to keep up with a computer. You have to prepare everything ahead of time. This results in an application that gets installed on a computer that the user can then run and interact with. Any bugs in your application will be noticed by your users. Some will be minor and hopefully you won’t have too many that result in the user losing work. I know that I’m not very happy when I spend time creating something only to have a bug cause it to be lost.

You might wonder why programming languages look so strange. Why do they have all those special characters? How will you ever learn when and where to use parenthesis instead of square brackets? Well, there’s a perfectly good reason why we can’t program in English, or Spanish, or Arabic languages. All the spoken languages leave too much unsaid. They rely on another person to fill in the missing pieces. It takes another person to know how to combine what was said with whatever’s going on to be able to make any sense of it. And even then, we often get it wrong.

A programming language allows you to write your instructions in such a way that the computer knows exactly what to do. Notice that I didn’t say that the computer knows what you want it to do. This is why I like languages that are more strict. They force you to state ahead of time what something is and how it can be used. If you try to go against this, then your program won’t compile. Remember I said that all languages allow some means to translate what you write to what the computer can understand. This process is called compiling. When your program fails to compile, then that means it was written wrong and can’t be translated.

That’s actually a good thing. Because that’s a bug that has no chance to ever hatch. Compare this with a programming language that’s more accepting and you have a bug that makes it into your application. If you don’t find this bug in your testing, then your users will.