One question that people ask me all the time is, “How do I become a programmer?” Or, “How do I learn to program?” There are a lot of possible answers to this, depending on the person and how you want to go about it. I figured that since people ask me this so often, I had better finally write an article about it.
Find the Best Way
One rule that has served me well when I’ve been learning to program, no matter the method I was using, was to always ask, “What’s the best way to accomplish this?” or “What’s the right way to accomplish this?” That is, in programming there are many different routes you can take to accomplish your task. But usually, only one of those is the recommended way, either in terms of the most modern way to do it in your programming language, or the best practices that the community of programmers have agreed on based on experience. Usually, you can find out this information by reading the documentation of the programming language you’re learning, or searching online for a best practice via Google or Stack Overflow. If you can’t find the answers, ask the question on a forum, mailing list, or Stack Overflow. I still do all of this, to this day, when I’m given a task where I have to learn something that I don’t know about.
The advantage here is that you don’t just learn to program, but you learn to be a good programmer. Also, it forces you to really dive deep and understand the tools and languages that you’re using. If you do this continuously as you go, you eventually develop a good, deep understanding of the systems you’re working with, while maintaining enough practicality to keep yourself interested. (That is, you are only diving this deep on the things you’re actually doing something with—not random theoretical stuff that you’re never going to use. That can be interesting too, but it’s not an educational system that you can use forever to really learn to program.)
Of course, you have to make sure that you really understand everything you are reading when you do this. That might mean diving down into more documentation, and then even more documentation, until you understand all the words and symbols being used. That’s okay! That’s a big part of what makes this system work—that you gain a true, deep understanding of the symbols and concepts you’re working with.
Now look, to be clear, when you’re first learning to program and you’re given a challenging task, it’s okay to just try to get it done any old way you can. You’re learning the basics, not the best practices. This piece of advice is for once you get over the hump of learning the basics of how to get anything done at all. For a project that you’re doing purely to learn something, the most important part is that you learn the thing you’re setting out to learn. But once you’ve got that in hand, delve deeper into it and try to see if you’ve done things the best possible way.
Okay, now that said, let’s talk about the different methods that people actually go through to learn to program.
The most commonly-taught subject that’s related to programming in universities is called “computer science.” I say that it’s related to programming because very little of what people learn in most computer science courses will actually end up being useful in their day-to-day lives as a professional, working programmer. That’s not always true—there are some fields where computer science comes very much in handy. But in general, the field we call “software engineering” or “development” is different than what universities cover as “computer science.”
Usually, the basics of computer science that universities cover are very useful. I went to university and studied computer science, and my first two years of study were very useful to me, especially the first few classes. I got a great grounding in some of the basic concepts of software development.
What I didn’t realize at the time, though, is that computer science is only partly a study of programming. The other part is a study of algorithms. (For those who are reading this and don’t know, an algorithm is a series of steps for accomplishing some task. That’s really all it means. Even a shopping list is a sort of algorithm.) The study of algorithms usually involves learning the most efficient way to do something. That is, figuring out how to accomplish a task like sorting a list of integers using the fewest number of steps or using the least amount of memory. There are some problems that can’t be solved by computers at all unless you know the right algorithm, and once in a while you run into a problem in programming that requires this knowledge. So it does have some use. But solving these problems of algorithms is not what you will be spending most of your time doing.
Even for those universities that offer courses in “software engineering,” they are rarely a full experience of what the real world will be like. The reason is that most courses only take a few months at most, and make you collaborate with only a few people at best, on a codebase of a few thousand lines of code. In the real world, you will be working with a large number of people on a codebase that will last for years that is at least tens of thousands of lines of code. However, these software engineering courses are still far better than nothing.
All this said, there are a few universities that do turn out excellent programmers, whether that be by computer science courses or software engineering courses. And there is always some value in learning to program by taking classes at a university. At the very least, being at a university provides a structure and discipline that encourages you to get through the class.
On the other end of the spectrum from university training, many programmers are self-taught. They read up on some documentation online, mess around with things, somehow get those things to work, and eventually become competent programmers through a lot of painful, hard experience.
A lot of how I learned to program was this way. The most important thing for me was to have some task that I wanted to accomplish. You see, programming is a tool, it’s not an end in itself. It’s a system that you use to accomplish something else. So you have to have something you want to accomplish. Sometimes you have to make up that task yourself. For example, a friend of mine had an idea for a very simple game. So one summer, I spent several weeks learning Java so that I could write that game. I already knew the basics of programming in another language, C, from my university classes. So I wasn’t entirely new to programming, which helped a lot.
What I did (and what I recommend that most people do if they want to learn some language) is I just went through the official tutorial that the creators of the language supplied. For me, this was an older version of the Java tutorial. Almost every language has one of these official tutorials, or at least recommends some website where you can learn. Usually you just have to search Google for the name of the language you want to learn followed by the word “tutorial” and you’ll find what you’re looking for. Or go to the main web site for the language you want to learn and look over their “getting started” links.
Now, if you don’t know how to program at all, there are some other things you might have to learn first, depending on your level of experience with computers. You might have to learn a bit about how computers work, how to edit text files, and how to run programs via the command line (since that’s usually how you’ll be running your first programs). A lot of this is simplified nowadays by using a web-based code editor, though, where you can just write code and run it right there in your web browser. To find one of these, just search for the name of your language followed by the words “web editor” (without quotes) in Google.
Once you’ve taken the tutorial for some language, there are a lot of ways to go to teach yourself how to program. Google and Stack Overflow are definitely your friend, as are the official docs for the language that you’re using. A lot of what I would do when I was teaching myself was I would search through the official docs of the language for words related to what I was trying to do, and then just read those docs to understand what I was trying to accomplish. But the key here, as I pointed out above, is that you have to actually understand. If you’re very very new to programming, sometimes it’s okay to just copy and paste some code and not understand what it does. But usually that gets you into hot water very quickly, even in terms of your own understanding. You’ll find that something doesn’t work, and you will have no idea why.
In fact, not understanding why something is broken is one of the most frustrating parts of teaching yourself to program. I would guess that this is where most people give up. Something doesn’t work, the system outputs some totally cryptic error message, and they don’t understand how to fix it. This is always, always because the programmer didn’t understand something about the programming language, the tools they were using, or what the words in the error message mean. This happens most often when you have cut and pasted something without fully understanding every word and symbol in the code that you copied.
Now yes, it might seem like a lot of work to go through and learn what every single word and symbol really mean, but that’s how you learn to program. Programmers aren’t valuable to society just because they know where and how to copy and paste stuff from Stack Overflow. They are valuable because they have learned and understood certain concepts, and how how to apply them. You’re actually increasing your value as a programmer by doing this.
However, it’s still often very frustrating to try to get through this process without any kind of help. Hopefully, if you’re doing this, you have somebody you can reach out to when you get totally stuck, who can help answer your questions. I didn’t have anybody, and sometimes that was very rough, where I would spend 30 hours staring at a piece of code, tearing my hair out trying to understand why the dang thing didn’t work. So if you have somebody you can talk to, that’s often better than trying to just figure it out on your own, especially when you’re just starting out. Sometimes reading all the documentation for a thing when you’re brand new to programming can be overwhelming. It helps to have a guide, or at least a helper.
Somewhere between university training and teaching yourself comes “coding bootcamps,” a phenomenon that has arisen in the last few years where an organization claims that it can teach people to program in X weeks or Y months. Very often, these programs actually provide a better and more practical education than universities do, although some of them don’t quite give you the theoretical depth that university training would give you. That is, you don’t learn as much of the theory behind programming (in particular, the basics of how to program well) that you might learn from some more formal training.
Here’s what I would say as a guideline: if a program promises to teach you to program in less than a month, it’s probably garbage. You could maybe learn some of the basics of web development in that time, but you could never learn to be a professional programmer with just four weeks of experience. Gaining basic skill as a good programmer is a process that takes at least months, as far as I’ve seen from seeing the results of various bootcamps. You might get enough of the basics in a few-week class that you could then go on and teach yourself the rest, but a month of programming isn’t going to turn you into a professional developer.
Now, this all might sound like I’m pretty down on bootcamps, and that the only way to be a “real programmer” is to suffer through the pain of teaching yourself. However, nothing could be further from the truth. In fact, I’ve seen great products come out of bootcamps. Personally, the best programming school of any kind that I’ve seen would probably be called a “bootcamp” these days, and that’s The Tech Academy. They do a good job of taking people who don’t know how to program and making them into programmers, and it’s what I always recommend to people when they ask me how to program if they don’t want to just teach themselves. There are probably a lot of other decent bootcamps out there, too.
If I were evaluating a bootcamp today, I would find out how many of their graduates got good jobs as professional programmers and try to find some of those graduates and ask them how relevant their training was to what they are actually doing on a day-to-day basis.
Once you’ve taught yourself the basics of programming, either through university, self-teaching, or a coding bootcamp, one of the most important things you can do in terms of your career is pick some good first experiences that can help you grow as a software developer.
If you are a university student, I strongly recommend that you take advantage of the summer internships that many software companies offer. It’s the best way to have a low-risk experience of what working at an actual software company is like. Most of the companies will actually pay you, and it is also the easiest way to get hired at that company after you graduate. Since they already have experience with you, the hiring process is much easier.
If there is some open source project that you really want to work on, try to see what they need and just go work on it. Very often, open source projects have a list of available tasks for newcomers, and you can just pick some task and start to get to work on it. The advantage here is that there are usually no deadlines, and there is usually a community of very supportive volunteers who can answer your questions on mailing lists, in chat rooms, etc. Since most open-source projects engage in a process called “code review,” you will also get feedback on your code from a more senior engineer, which will also help you grow as a programmer. On top of all of this, working in open source provides evidence of your work that you can show to any employer. (When you work on code for a company, you usually can’t then take it outside the company and show it to other prospective future employers as evidence that you are a good programmer.) Also, companies usually like to see open source participation on your resume, since it shows that you’re interested in and passionate about programming.
When you take a first job as a programmer, consider the opportunities that it will provide you to become a better programmer. Does the company have more experienced software engineers who can help you grow, or is it composed entirely of new university graduates with little to no professional experience? Does the company do code review, where each of your changes is reviewed by a more senior engineer to help you get better at programming?
And perhaps most importantly, when you accept a job, make sure that it’s a company that cares about software best practices. This is more frequently true in software companies—that is, companies where their primary product is software—than it is at other companies (for example, financial institutions employ a lot of programmers, but whether or not they care deeply about software quality depends a lot on the company and even what part of the company you work in). You’re more likely to have this experience at a company that’s a bit more established, or at least at a company that’s not under terrific deadline pressure and about to die (like a startup that’s running out of money, for example).
I’m not saying that you should refuse the only offer you have just because they might not be the perfect company to work for. But keep in mind that if you’re looking for career and skill growth as a programmer, you’re not going to get it by hacking out poor code on tight deadlines for users who hate your product but are somehow forced to use it anyway.
There is a lot of content online about software best practices. There are also a lot of good books. (I even wrote some of those books, which you would probably like if you’re learning to program.) It’s worth reading up online about various software best practices, especially when they pertain directly to some practical problem you’re actually trying to solve. Continuing to read books, blogs, websites, etc. is a good way to stay up to date, sometimes even when they’re not directly practical. Once in a while, for example, I’ll go read up about some new programming language or some CPU feature, not because it has anything to do with what I’m doing, but just because it seems like good and useful information for me to know as a programmer.
That’s the basics of the advice I usually give people when they ask me how to program. There are probably other things to know, especially the stuff I covered in Why Programmers Suck. And of course, all of the above is just a summary of a process that takes months or years to really get good at. But hopefully, this helps you learn to program, or provides you a resource that you can send other people when they ask you the same question!