Wednesday, February 13, 2013

How to Learn to Code (a Guide for Non-Geeks)

The other day I was reading an article in The Atlantic called "How I Failed, Failed, and Finally Succeeded at Learning How to Code." It tells how the author, an ordinary mortal named James Somers, decided he wanted to learn how to code, so he bought a huge tome called Beginning Visual C++ and just started reading it. But he quickly became overwhelmed and quit.

After several false starts, Somers finally made it over the hump. He credits his success with trying to solve some of the problems at Project Euler. He credits his early failure with having had poor teachers (in the form of bad books; his term).
Learning to program: a lot of wax on, wax off.

Many people have had the Somers experience, I'm sure. Some don't even get that far, of course.

There are plenty of people in this world who wish they could read and write code but who haven't pursued coding, based on fears that it will take too much time to learn; be too hard; require too much self-discipline; require too much understanding of math; or whatever. Some no doubt think formal classroom training is their best and only learning modality. "I should have taken a programming class in college."

Here's what I would tell somebody who wishes he or she could code but doesn't know if it'll be worth the effort (or even possible).

First, I've met scores, maybe hundreds, of talented programmers in my life, and many of the very best ones were self-taught. All were mere mortals. Sure, some were superstar genius types who could have taught themselves Sanskrit if they wanted. Most were not.

So: You don't have to be a genius to learn how to code. And you don't need formal training. You can teach yourself. It does help (a lot) to have a mentor to turn to. But even that part is optional.

Does it require math skills? No, not really. Somers, in his Atlantic article, leaves the impression that it helps if you're naturally interested in math puzzles. I strongly disagree. Programming is about logic, not math. The main requirement is that you understand the basic concept of if this, then this; if not this, then that.

So really, the question is: What's the best way to teach yourself?

First, choose a language. To me, the choice is brain-dead obvious: JavaScript. Where programming is concerned, it's the lingua franca of the Web. Sure, if you specifically want to become a systems programmer or a Linux geek, you might want to consider C++ or Java, or even start with Linux shell scripts. But the neat thing about JavaScript is, the basic syntax is the same as for C, C++, or Java. Once you've learned JavaScript, you have transferable skills.

Another good thing about JavaScript is that it's powerful, but not powerful enough to blow up your machine. It has designed-in safeguards. You're never going to overwrite the boot sector of a hard drive with JavaScript, nor overwrite screen memory, nor take down the operating system. That's important, because one all-too-legitimate fear many would-be programmers have is that they'll unintentionally do something that leads to loss of data or ends in horrific non-undoable mayhem of some sort. JavaScript is comparatively tame in this respect. Bjarne Stroustrup once said that while the C language makes it easy to shoot yourself in the foot, "C++ makes it harder [to do so], but when you do, it blows your whole leg off." He might just as well have been comparing JavaScript (rather than C) to all other languages (rather than C++).

Programmers love to argue (to death) the merits of one language over another. But the simple truth is that all programming languages do the same things. They all have conditional statements (if/else), they all let you use variables, they all have a construct for doing loops, they all have a way of dealing with strings (text), they all have some notion of subroutines (or "functions" or "methods" or "procedures"). So in a sense, it doesn't really matter which language you choose to learn first.

How should you teach yourself? You'll find no shortage of resources online, but if you're like me, you probably relish the opportunity to cozy up with a reprocessed tree (a plain old book). You can buy a Dummies-style book or just go ahead and grab Learning JavaScript by Shelley Powers and start reading. You should also purchase Flanagan's classic JavaScript: The Definitive Guide (O'Reilly) as a reference; you'll eventually want it, trust me.  

Here's what to expect. You won't be writing much code for a while. You need to take in a lot of preliminaries first. In fact you'll take in so many preliminaries that eventually you'll start to feel like you're not getting it. You'll have a tremendous number of seemingly useless facts in your head about data types, how to declare variables, "execution scope," and so on, and you'll fear that none of it seems to be tying together; it's just hurting your brain, and you have nothing to show for it.

When you get to that point, you've reached what I call the WOWO Point. Wax On Wax Off. You saw The Karate Kid, right? Remember all the "motions" the kid had to go through to learn karate? Mr. Miyagi had the kid doing repetitive, menial drudgework like painting his fence, sanding his floor, and waxing his car, for what seemed like forever, and for what seemed like no purpose at all. The kid was just about to lose patience and give up on Miyagi, when he suddenly has the critical breakthrough. He suddenly has the muscle memory, mental discipline, and reflex skills to begin doing karate for real.

This is what happens also with programming. You do a lot of "wax on wax off," feeling like you're learning a lot of gibberish for nothing, and then suddenly you put the elements together and bang! it begins to make sense. At that point, you realize you're free to create, not just absorb. It's kind of like learning any language: You start with rote memorization of vocabulary and syntax rules. You acquire a lot of useless junk in your head. But once you've internalized the rules of the language (and some vocabulary words) you realize you're now free to construct sentences on your own, not just use and reuse sentences you learned by rote out of a textbook. Something similar to that happens when learning a programming language.

Tomorrow I want to continue on this theme by presenting a first programming lesson (in JavaScript), for raw beginners, a lesson for total non-geeks who are curious about learning to code. The purpose will be to prove to you that programming is not "rocket surgery."  Anyone can do it. Tomorrow you'll see!


  1. This is a great read. And as somebody who was self-taught and has done programming for many years, I disagree completely...

    Just kidding. There's no right or wrong way, you should do what works for you.

    Personally, if I could start over, I would start with Objective C iOS programming over javascript. It sounds crazy, but as you point out, all programming languages pretty much do the same thing. The advantage of IOS is that its rather limited in what you can do. If you stick to Apple's human interface guidelines, even more so. Javascript, on the other hand, is vast. I think that limitation is important initially, even if the language is considered to be "harder", its really not that hard. All of them are derivatives of C anyway. And with ARC, they took out the most intimidating part IMO: memory management.

    Actually, before diving into any programming language, I would highly recommend taking a deeper dive into understanding what it is that computers actually do. If you're going to do javascript, I would extend that to understanding client-server relationships. I would also probably introduce debugging very early. It need not be overly complex, even simply commenting out everything and then uncommenting until you figure out what's broken seems obvious but isn't to many people.

    Oh, and for pete's sake, don't let them copy and paste code. Even if you're copying it verbatim from a book, typing is better than copy and pray.

    Again, this is just personal opinion. Probably not even 2 cents worth..

  2. Anonymous1:54 PM

    Good article, and I concur on many points - on one, however, I strongly disagree. JavaScript is not a good start, sorry to say so. It is quite different from C/C++/Java in many regards, it just shares a similar syntax - sometimes.
    You'll have to limit your course very carefully to the areas that are similar. Best of luck with that!

  3. As someone who's only about a month into learning to program and has spent days trying to debug one tiny piece of code, this is a very encouraging article!

    Also nice to know being a math superstar is not required! That's the one thing I keep worrying about!

  4. Anonymous7:25 PM

    Thanks for the morale boost.

    I'm learning JavaScript on my own and am on my third book. I finally found one that EXPLAINS it rather than just asking you to copy what they are doing.

    I understand if, then statements and creating variables. Mostly I am finding it difficult to hear/read why to use JavaScript on Web pages.

  5. I has suffered for Human papillomavirus HPV) for 2years, I was given some tablets at the hospital but I refused to take it, They said I have to be on it for life so I don't want take a drugs everyday for life. No point in taking medicine everyday when u won't get cure from it and I was advice to seek for natural herbal cure, after some time I found dr onokun is the most trustful herbalist that have herbs to cure wicked symptom's,I emailed dr onokun, for 2weeks been his patient he cured my (HPV) with his herbal. I only used his natural herbs for two weeks it was 100% cure. I'm not (HPV) patient anymore. I'm happy about it i finally got cured out of this mess been in my body for 2years. I also recommend you if you're living with (HPV) or herpes symptoms i also want you to be free contact dr onokun with the email attach to my post.

  6. Our company has been providing Best Writing Services to our clients for more than a decade. We have specialized in the delivery of an assortment of Custom Essay Writing services among others.

  7. I'm 61 years old, I contracted hpv in 2011' I has be taking lot treatment for it and some months ago the wart stated coming out seriously, I used lot recommendation because there was lot warts around my anus and was so embarrassed. but today I'm totally happy I got the virus eliminated by using natural treatment from Dr Onokun herbal center after his treatment I got cured. all the warts went away' seriously believed Dr Onokun he have the cure for human papillomavirus because he has eliminated hpv been in my body since 2011, Dr Onokun make it possible for me. Here is Dr Onokun email to reach him: he is welled capable of curing terrible diseases.

  8. Life is always beautiful when you have good health. For almost a year had Hpv and I was lonely and sad luckily I was directed to a very kind and Great Dr Onokun who helped me cure my Hpv and today I am free from Hpv and very healthy thank you so much Dr Onokun Email him via:  or website: or

  9. 5 years ago I had warts, I was treated with some liquid applied to the warts they continued to grow and spread... The next 2 doctors did laser surgery to remove them. 1 year after the surgery, they grew back close to where the 1st ones were' so I was finally told it was hpv. I have had it for very long time, I contract it from my cheated boyfriend and I found out he was also infected and I end up the relationship between us. the warts was so embarrasses because it started spreading all over I have be dealing with this things for very long time the last treatment I take was About 2 years ago I applied natural treatment from Dr onokun herbal cure, a week after applying the treatment all the warts was gone. it's now 2 years and some months I don't have single wart or any symptoms of hpv. wow"" it's great, Dr onokun has finally cured me. Anyone living with hpv contact Dr onokun for natural treatment.
    His email address: Dronokunherbalcure@gm‎

  10. DR OYAGU herbal medicine is a good remedy for herpes simplex virus cure. My name is MIGNON WRIGHT , am from USA,I am here to give my testimony about DR OYAGU who helped me in my life, i want to inform the public how i was cured from (HERPES SIMPLEX VIRUS) by DR OYAGU, i visited different hospital but they gave me list of drugs like Familiar, Zovirax, and Valtrex which is very expensive to treat the symptoms and never cured me. I was browsing through the Internet searching for remedy on HERPES and i saw comment of people talking about how DR OYAGU cured them, when i contacted him he gave me hope and send a Herbal medicine to me that i took and it seriously worked for me, am a free person now without any problem, my HERPES result came out negative, I pray to God to never let me and my family forget you in our life,am now cured permanently, you can also get your self cured my friends if you really need this doctor help, you can reach him on his website Email: or via whatsapp +2348101755322

  11. I appreciate your hard work. Keep posting new updates with us.
    Hire 8 Seater Car Sydney

  12. Hi Friends i am so glad to writing this article today to tell the world how Dr odoma cured my HSV VIRUS,i have been detected with HSV-1 AND HSV-2 since five years ago, ever since then my life has been in complete bizarre and agony,i have used so many drugs that was prescribed to me by several doctors,but it didn't cure my HSV VIRUS neither did it reduce the pain,until a certain i was checking for solution in the internet,then miraculously came across Dr odoma the powerful herbalist that cure numerous individuals HSV-1 AND HSV-2 INFECTION,then i contacted his whatsApp number at +2348100649947 or    i explained everything to him and prepared a cure that cure my HSV-1 AND HSV-2 disease totally after receiving his herbal medicine, so my friends viewers why wait and be suffer when there is someone like Dr odoma that can cure any disease HIV/ CANCER/ HEPATITIS B VIRUS, you can contact his via : or WHATSAPP +2348100649947

  13. Hey there! I simply would like to offer you a big thumbs up for the great information you have got here on this post. I will be returning to your blog for more soon. Feel free to visit my website; 먹튀검증가이드

  14. Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up Feel free to visit my website; 배트맨토토프로

  15. Hі there, every time i useԀ to check web site posts here early іn the dawn, since i enjօy to find out more and more. 스포츠토토

  16. I’m not that much off a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your site to come back later. Many thanks. 파워볼사이트

  17. Please keep us informed like this. Thanks for sharing. 바카라사이트

  18. When did it start? The day I started surfing the Internet to read articles related to . I've been fond of seeing various sites related to 안전놀이터 around the world for over 10 years. Among them, I saw your site writing articles related to and I am very satisfied.

  19. I’m impressed, I have to admit. Truly rarely should i encounter a blog that’s both educative and entertaining, and without a doubt, you’ve hit the nail within the head. Your notion is outstanding; the pain is an issue that insufficient everyone is speaking intelligently about. I am very happy that we stumbled across this inside my try to find some thing relating to this. 메이저토토추천


Add a comment. Registration required because trolls.