How you can learn more by writing code than by reading it
When you’re learning to program, you’ll often hear the advice “learn how to read code”.
The idea is that by reading code, you will see how other people do it and you will pick up on it, and learn new techniques and ideas. That’s like saying you can improve your walking technique by watching other people run - and you haven’t yet learned to walk! In linguistic terms, you don’t know how to ask where the bathroom is, and you’re sitting down to read something that could be a technical manual for hydraulic toilets or could be a guidebook to the most luxurious bathrooms in France!
I know I sound ridiculous. I sound ridiculous for saying you can learn more by ignoring everyone and focusing on your own programs. What if you don’t know how to program? If you’ve ever done a hello world tutorial, you can program. You won’t be able to do as much as you want, and you won’t be able to do as much as other people, but you will still be able to write an endless number of programs. Most importantly, you will be in a position to learn more by asking questions, reading lots of documentation, and yes - learning from other people’s experiences.
Here’s my 1-step guide to becoming an expert programmer:
Step 1. WRITE 100 PROGRAMS
If that doesn’t work for you, try again. And again, and again, until it works. I promise you it works. It’s what I’ve done to develop my career over the past ten years.
You’re probably wondering why you should write so many programs, instead of reading other people’s code. Writing code is the best way for you to develop your sense of coding style. You will express ideas, and you will experiment. You will feel things as you write code and read it over, and you will incorporate those feelings into your regular work as a programmer.
This goes double if you’re just getting started. You don’t want to try to understand someone else’s style before you’ve started to understand your own. There will come a time when it makes sense to read someone else’s code, and where doing so will challenge your coding sensibilities. I do not think that time comes until you’ve written at least 100 programs, and I do not think that time comes regularly for more experienced programmers. You will spend plenty of time reading other people’s code as part of your work - it will quickly become a part of your daily practice.
If I can go into old geezer mode for a moment (hey, I just turned 29 the other day)… I really wish I knew about version control systems when I was first learning to program. I remember some cool programs I wrote - poker simulators, my first web application, “love programs” I wrote for valentines (not as romantic as I’d hoped). I don’t have the source code for them anymore, and I’d love to have them. They’re like old records, I guess. Anyway, if you’re reading this, then I’m sure you can find access to free version control hosting. I highly suggest keeping copies of your programs in version control. You will build up good habits, practice skills that are critical to your success as a professional programmer, and have a logbook of everything you’ve done. This can be very motivating, and it will definitely be valuable when it comes to remembering something you’ve done. It’s also a great starting point for a portfolio.
Reading is the secret to your success
When I was a kid, my favorite tv show was reading rainbow. It still blows my mind that they had a tv show about books and reading. It blows my mind even more that Levar Burton just raised the most money in kickstarter history to bring it back and put it in more homes and classrooms than ever before.
Anyway, my point is that reading is not only important, it’s also amazing and will make your life better. If you read anything right now, make it the error messages. Make it anything on the console. Read every last little piece of information that the computer feeds back to you as you use it, because that is the most relevant and useful information you will ever get. Read the documentation for the software you use - the majority of software out there has no documentation, or out-of-date documentation, so if you do come across a project with comprehensive, useful documentation, you have struck upon a gold mine. Too many newbies ignore the documentation, and don’t read command line output because they don’t understand it. Newsflash: the only way you’ll learn to understand it is by reading it and figuring it out. I use google all the time, but I still have to figure out what it is I’m looking for.
Once you have a habit of writing code, and reading computer interactions and documentation, you should incorporate reading other people’s code. Expand as much as you can and read as much code as you can. See what’s available and incorporate what you learn into your work. But don’t do that until you’ve developed a coding style. Don’t do it until you’ve developed a coding lifestyle.
Related: The two DHH-approved programming habits that will make you a good programmer