You’re about to spend several minutes of your life reading a blog post. As a mediocre nerd, I’ve spent some time lurking around people—in taxis and computer labs, observing their behaviour while I’m pretending to read the latest Sqoop magazine.
For that reason, I’ve learned that if you have followed this post’s link and read up to this very paragraph, I only have approximately 11 more seconds before you close this tab and launch some kind of app that lets people compare their lifestyle to that of their counterparts, as well as share memes 24 by 7 by 365. (That phrase has always bothered me. As a failed horologist, I expect it to either be “24 by 365” or be “24 by 7 by 52”.)
So l’ll be brief: Computer programming is easier than it looks.
Are you comfortable enough with a computer to send an e-mail, prepare a nice-looking résumé, or share your holiday photos? Well, congratulations! You can write computer programs.
This writing is intended for non-programmers and those new to programming who think they hate this stuff. However, if you already have some experience under your belt, it doesn’t mean you should stop reading. Just that this is basic stuff—you’re a programmer, and you know what a compiler or an interpreter is, so I’m not insulting you. No condescension intended if you know these things already.
I’m sure you’ve heard that programming is esoteric and insanely difficult. Some might have told you it requires an honours degree in computer science, a keen analytical mind, millions of shillings in hardware and software, and a strong appetite for caffeinated drinks.
All that is wrong! Though the caffeine part, um, is probably true.
What is programming, anyway?
It is simply getting a computer to do what you want it to do (or what your user wants it to do).
Programming helps you communicate instructions to a computer; instructions that will tell the computer how to carry out your plan for solving a problem. To give instructions to a computer, we write code in a programming language. A programming language specifies the rules for the code we write and dictates what the computer does in response to that code.
You should learn to take control of your computer by going beyond what can be done by an end user using pre-existing programs. Write your own programs. I’m not asking you to write another spreadsheet or a word processor or an image editor. Those are huge tasks that, fortunately, people have already done. Rather, learn how to write small programs to solve problems that we otherwise wouldn’t be able to solve.
Is it Hard? (the myth)
In PyCon 2015, Jacob Kaplan-Moss gave a very interesting talk titled The programming talent myth, which I’m going to directly highlight a thing or two from.
First is the saying that people “suck at programming” or that they “rock at programming”, without leaving any room for those in between. Implying that everyone is either an amazing programmer or “a worthless use of a seat”.
Because of this bad myth, where the only options are to be amazing or terrible, people believe they must be passionate about their career, that they must think about programming every waking moment of their life. Should they fail to do that, they’ll slide right from amazing to terrible again. So, people work crazy hours at work, constantly study programming topics on their own free time, and so on.
This myth is even aided by a strong belief that programming is an innate talent that people are born with. Those who do not know how to write software and who believe in the myth fall into a trap: thinking that their age has reached 30 or 20 or 15 (or even 40 or 60) and, because they haven’t written any code yet, that means that they never can or will.
The truth is that programming isn’t a passion or a talent, it is just a bunch of skills that can be learned. Programming isn’t even one thing. It requires a bunch of skills, and coding is just a small part of that. Things like design, communication, writing, and debugging are needed.
Like any other skill, you can program professionally, occasionally, or as a hobby, as a part-time job or a full-time job. You can program badly, program well, or, most likely, be an average programmer. If we embrace the idea that “it’s cool to be okay at these skills”—that being average is fine—it will make programming less intimidating for newcomers.
Read a full transcript of his talk here
Why Should You Care?
If you’re looking for reasons why you should learn to program, check out You Should Learn to Program by Christian Genco. He mentions a few things, including the fact that programming literally makes you smarter and that computers are getting faster and can do a better job in some areas than a human brain.
“Is the effort to learn programming worth it?” Just like Richard Hamming once said, to answer this, you must ask people. When you get beyond their modesty, most people will say, “Yes, doing programming, and knowing it, is as good as wine, women and song put together,” or if it’s a woman she says, “It is as good as wine, men and song put together.” (I may have paraphrased it a little, though).
Truth be told, programming is fun and delight for a few reasons, as mentioned in The Mythical Man-Month;
- The sheer joy of making things. As the child delights in his mud pie, so the adult enjoys building things, especially things of his own design.
- Pleasure of making things that are useful to other people. Deep down, we want others to use our work and find it helpful.
- Fascination of fashioning complex puzzle-like objects of interlocking moving parts and watching them work.
- The joy of always learning, which springs from the non-repeating nature of the task.
The fourth point has been my favourite of late. I can say with confidence that programming isn’t for you if you don’t like the fact that you’ll always be learning.
How the Heck do Programs Work?
The collection of statements that make up a computer program is called its source code. Source code, or code that we can read and write (just like an email—by typing each statement into a text window), is saved to a file with the appropriate filename extension to indicate what type of file it is.
Now, we need help to turn this code into a program that our computer can actually run. We can either use an interpreter or a compiler, depending on the programming language. A compiler is a program that can convert one language to another, such as source code to machine code or zeroes and ones that represent instructions that tell our computer to perform low-level operations. On the other hand, an interpreter examines each line of a computer program and executes that line, then proceeds to the next line.
Tools called IDEs, integrated development environments, ease our work even further by including features for us to write, translate, and run our code.
As always, there are those unusual languages which require both a compiler and an interpreter. The compiler converts the statements into bytecode which can then be run by an interpreter.
Help! It Doesn’t Work
Many new programmers become discouraged when they start to test their programs. The compiler or the interpreter throw a fit and yells at them with error message appearing everywhere. Sadly, there are enough of these kinds of errors in every programmer’s career to write several 1000-page Pickaxe books.
Luckily, as you begin writing your own programs, you become well acquainted with errors that you even become suspicious whenever you don’t get them. They become a natural part of the process. Programming errors are called bugs, and the process of fixing errors is called debugging. Whether you want it or not, you get a lot of debugging experience as you learn programming.
Tada! First-ever bug: [1]
You can’t blame the computer when something goes wrong in your program. Computers do exactly what you tell them to do, so the blame for any errors usually lies with the programmer. But worry not, you can’t do any permanent harm. No computer will ever be injured as you learn to program.
Learning new stuff can be difficult. To me, that’s part of the fun. You didn’t learn, say, reading and writing overnight. You are unlikely to become a programming expert by lunchtime, either. Furthermore, you will get stuck. When you get stuck, here’s my two-point advice for you:
- Never ever silently give up.
- Get help.
The first point is very important. Many have tried programming, got stuck and given up, and not told anybody. If you don’t know about a problem, you can’t fix it. You’ll lose hair, friends, and a piece of your sanity.
The best way to get help is to first google; if Google can’t help, ask a guru. With the global adoption of the internet—the fact that you’re reading this, gurus suddenly are as close as your Enter key. So, find one and let them help you.
That’s it folks. You’ve been introduced to the concept of programming—giving a computer a set of instructions that tell it what to do. Remember, to gain experience, there is no substitute for one’s own effort. Go forth, then, and use computers as tools to solve problems.