Ask HN: What is your best way to learn a new programming language?
I had the same question when I wanted to learn C++.  I was already quite practiced at Java and had written C and had read books on C++ off and on for years, but I still could not program in C++.<p>So I got a copy of Stroustrup &quot;The C++ Programming Language&quot; and started to do his exercises, but the author clearly had never done them himself, some were quite long and tedious and did not teach me anything (never put exercises in a book that you have never done), so I gave up on doing his exercises.<p>In my exasperation I just made up my own exercises: I just started at the beginning of the book and for each feature the book mentioned I wrote a little program that used it.  The book said you can throw any kind of object, including, say, an int, so I wrote a program to throw and catch an int.  I have never done that before or since, but I did it.  I wrote a little program for every feature of the language.  It was incredibly tedious, but it worked.<p>I also compiled every program with two C++ compilers and ran them and compared the difference.  Many of my little programs did different things in the two compilers (!).  I coded for 10 hours a day for two weeks; when I was done, I could code in C++, I could think in C++.  Don&#x27;t despair if it takes you longer: recall that I was already an experienced programmer.<p><i></i><i>SECRET SAUCE HERE</i><i></i>: The key here was to actually write the program even if I was <i>sure</i> I had nothing to learn from it because the feature in question was so <i>conceptually</i> simple: you think you know something, but then when you go to actually type it in, you find out whether know it was well as you thought you did.  The tiny improvements you make while doing this copy-check-repeat feedback loop is the essence of learning the skill.<p>Note that no mistake is too small to be worth correcting.  It is critical to not say you have passed the exercise until you can produce the result <i>exactly</i> and <i>reliably</i>, as a matter of course.  If you just wrote a program and it was easy, then hide it and write it again.<p>At one point I was embarrassed that I could not write makefiles, so instead of copying them and hacking on them, every time I needed one I wrote it from scratch; now I am a master of gnumake.  I repeatedly write fizz-buzz, binary search, heapsort, hashtables, etc. over and over, just to make sure I can do it correctly and without effort.<p>One of Richard Feynman&#x27;s wives left him, legally accusing him of spousal abuse because he did too much c1alculus: <a href="https:&#x2F;&#x2F;www.theguardian.com&#x2F;science&#x2F;2011&#x2F;may&#x2F;15&#x2F;quantum-man-richard-feynman-review" rel="nofollow">https:&#x2F;&#x2F;www.theguardian.com&#x2F;science&#x2F;2011&#x2F;may&#x2F;15&#x2F;quantum-man-...</a> &#x27;&quot;He begins working calculus problems in his head as soon as he awakens,&quot; Bell complained to a divorce judge. &quot;He did calculus while driving, while sitting in the living room and while lying in bed at night.&quot;&#x27;<p>Ben Franklin describes using this method in his autobiography of how he taught himself to write.  He dropped out of second grade and ended up as one of the best writers in American history (not to mention scientist, statesman, engineer, etc.)  He says he found writing he liked and practiced copying it and then checking that he had copied it correctly; see his autobiography for more.<p>Woz used this method to teach himself how to build computers: he had the designs of computers from Silicon Valley firms and he just practiced rote copying the designs over and over.<p>I tell you this as a former graduate student in Mathematics at Berkeley: The secret to learning is not reading a bunch of abstract ideas.  The secret is just running a huge number of examples through your brain; your brain then abstracts them <i>for</i> you.  There is no need to study a bunch of abstract rules.  <i>After</i> you have learned the skill this way, doing a &quot;master class&quot; with an expert where you return to what you have learned and examine it, think about it, refactor it, can also be helpful.  However do this <i>after</i> you have the skill.  The standard advice in Zen practice is the same: &quot;practice first, study later&quot;.<p>If you think that this cannot possibly work, then think of how you learned to speak your native language; did someone explain the rules of the grammar to you as a baby, or did you just rote imitate it?  Non-native speakers of English have asked me why a feature of English is the way that it is or what the rule is for a certain situation in English.  I tell them I have no idea.<p>Our school system lies to you completely.  LEARNING A SKILL IS NOT ABOUT THE CONCEPTS, IT IS ABOUT ROTE MINDLESS IMITATION UNTIL YOUR BRAIN HAS INTERNALIZED THE IDIOMS.  Your brain <i>cannot</i> memorize the massive amount of detail in all of the examples, so it <i>must</i> abstract them into idioms; once it has done that, you simply have the skill and you do not even know how you do it yourself.  How exactly do you approach a door and open it?  If you think you know, then please explain it to the teams of people at places like MIT who are trying to build a robot that can do that, because it is very complex.  You do it and you do not even know how.  But you can do it.