Wednesday, January 16, 2008

Read Programming Books

Although learning programming can be achieved via online tutorials, reading books is still the preferred way for systematic learning (see some discussions here, here, and here from author's point of view). Following list is gathered along my adventure on reading programming books, especially on programming language books (for books not requiring active participations, it is recommended that you follow advice from Charles Petzold). Some suggestions are easier to be said than to be done, therefore the list is also a reminder to myself.

1. Select the right book

Reading a programming book requires enormous time and energy. Before embarking on the hundreds-hour-adventure, it is justified to spend sometime to select the correct path. Sometimes starting reading an excellent book itself is an achievement. So which book to read? The simplest solution is to search in Google or Amazon and select those with enthsiastic reviews. Google/Amazon are always handy since you can get more details/reviews on books. There are alternatives of course, as we will discuss below.

If you just want to read great programming books without any specific topics, you are lucky since this important question has already been discussed again and again. For example, you may refer to this Reddit thread, or you can consult the opinions of some outstanding programmers/bloggers (e.g. Steve Yegge's recommendations here and here, Joel Spolsky's advice, and Jeff Atwood's list).

If you do have some topics in mind (e.g. one particular programming language), there are various ways in addition to Google/Amazon approach.

  • Lookup in Wikipedia. Typically for one programming language, there will be one related article. At the end of the article, there is one References section, where you can find some interesting links to books.
  • Consult the FAQ of the language newsgroup. Normally, language X has one corresponding newsgroup like comp.lang.X. Generally the FAQ (sometimes quite outdated) of the newsgroup contains some book recommendations.
  • For some languages with official website (e.g. Haskell, Perl, and Python), you can easily find book recommendations in the site.

Let's name a few commonly recommended books for some programming languages: SICP (a.k.a. Wizard Book) for Scheme, Practical Common Lisp for Common Lisp, Programming Ruby (a.k.a. The PickAxe Book) for Ruby, and Javascript, the Definitive Guide (a.k.a. The Rhino Book) for the Next Big Language.

2. Setup programming environment and prepare related resources

You can't learn programming without getting your hands dirty. To study one programming language, you have to install necessary package(s). "Modern" programming books (e.g. Practical Common Lisp, Programming Ruby, Javascript, the Definitive Guide, and Programming Erlang) typically have one chapter getting you started. If your book does not contain such part, you can always consult online tutorials to setup the environment.

Typically the package contains some kind of editor or IDE for developing. You need to familiarize yourself with them either by reading your book or tutorial. For Emacs users, you can install related mode and simply fire up Emacs.

If the book is not so cutting-edge, you can find abundant resources in the web: source code, discussion on exercises, and even video lectures. You can bookmark or download these resources for your future reference. SICP is an excellent example here: great video lectures, and nice wiki to discuss solutions to exercises.

3. Practice, practice, and practice

You can't learn a language without sustained practice. We will focus on the examples and exercises contained in the book here.

When you read one example, simply reading is not enough. It is better if you type the example and run it. Note: type, not copy & paste. The reason is the same as when you write programs. After compilation, you think your code has done what it's supposed to do. But typically you need several iterations to make it right. Similar thing happens for reading. You think you understand the code on paper, but actually you do not. You should type it in and run it to really understand it. When you type, you can think about the meaning of the code, syntax and idioms associated simultaneously. A more paranoid yet effective way is that you first read the example, and then enter it without even referring to the book. You then run the code, analyze the results, and compare your code with the example supplied in the book.

Now for exercises. Do them all if you can. Excellent books come with excellent exercises, if any. You could gain more insight when you employ the techniques you just learned. (If you have any doubt on the value of exercises, you can look at Steve Yegge's example on how doing exercises can change a person's view about a language.) If you cannot solve one problem with serious try, you can leave it for a while and attack it later. If you really cannot handle it, you can refer to the solutions, which you can typically find online. Believe me, you can easily find the answers to these hard problems of excellent books in the web.

4. Develop hobby project

When you have already read several chapters of the book and feel comfortable to write a few small programs with the language you just learned, you may consider to setup some hobby projects. You can use the project to automate some day-to-day tasks, either in home or at work. Or you may try to implement/interface some (emerging) cool things (e.g. Google Chart API or Ray tracing) with the language you are learning. Make sure the skills to complete the project match the skills you just learned. You may meet some problems you cannot handle with the skills you just acquired. Don't panic. Just peep the later chapters of the book you are reading, or Google around. Try to finish the project if you can (and then you can blog about it if nobody has not done so or your way is quite interesting). If you cannot finish it, you can leave it for a later attempt. You may try several such projects when you progress in the reading. The further you progress, the more ambitious task you can try. Such hobby project itself can be viewed as extended exercises, but designed by you, instead of the author.

(Note: this section is largely influenced by a nice article/post related to reading On Lisp. Unfortunately I cannot find the URL now.)

5. Never give up

The last but not the least advice is that you should read the book from the beginning to the end. Spending a lot of time on one book but giving it up when approaching say one third of it is just wasting time. Since you only touched the surface of the book, which is easier to learn and also easier to forget. Authors arrange the books in such a way that you could linearly read along, which typically means that advanced topics come later. You may get stuck with one chapter and cannot understand the topics discussed there. At this point, don't give up. Remember that you can only achieve a higher level of understanding of one language/technique if you can understand the difficult part of it. Just read it, understand it, try it, or Google around to find different (maybe better) treatment of the topic. Attack this gnarly problem and you will gain lots from it. You have now learned some unique things of the language, you can now look at the language in a different yet more insightful view, and of course, you can now proceed further to read the great book and learn more.

Happy reading!

Update (2010-2-21): editorial corrections (thank you justin for your suggestions).


  1. 你很厉害,英语写的还不错! 很佩服你们能够学好英语的中国人哈哈

    You can't learn programming without your hands dirty. 应该是 'getting your hands dirty'吧!

    这两句话很想中国式的英语: The reason is similar as when you write programs. After compilation, you think your code has achieved the task. 我觉得把similar改成the same, 然后把achieved the task改成done what it's supposed to就可以了!

    还有advice这个词绝对不能在后边加s! 很难听,我去过中国,那次听多了就有点想杀人!! 受不了了

  2. Thank you justin! The issues were corrected. Your Chinese is really good (I think it's better than my English).