Jeff Mesnil

Best First Books for Programming Languages

As a followup to my previous entry, this is the list of first books I wholly recommend to learn programming languages:

C
K & R
Clojure
Programming Clojure
Erlang
Programming Erlang
JavaScript
JavaScript: The Good Parts
Lisp
The Little Schemer
Objective-C
Cocoa Programming with Mac OS X 1
Python
Dive into Python 2
Ruby
Why’s (poignant) Guide to Ruby
Smalltalk
Smalltalk Best Practice Patterns

These books are not necessarily the most complete references and they do not cover all features offered by the languages but I found that they gave me the best insight to understand and think with these languages.

One language I did not list is Java. I have used Java for so long that the last introduction book I read was for version 1.2. Which book would you recommend to learn Java?


  1. This is more than just Objective-C but I found that learning Cocoa stuff really make the language shine. 
  2. I have not read Dive into Python 3 yet but I bet it is as good or even better than Dive into Python 

How Books Shape My Appreciation of Programming Languages

This morning, I read this funny tweet from @carina:

“Javascript in a single picture”: http://short.to/rwo6 – absolutely awesome. Not sure if I should laugh or cry now. ;)

Funny and true: there are few good parts in JavaScript but they are really good!

I first learnt JavaScript by reading “The Definitive Guide” and I disliked the language. Browser incompatibilities, different DOM support were not helping too, but I found that the language was not “clean” (kind of object-oriented with this weird prototype thing).

A few years later, I had a renewed interest in JavaScript as a language running on the JVM. I also started to use jQuery and I was in awe with this library. I wanted to be able to read and understand jQuery code. I read “The Good Parts” (that I reviewed last year) and, finally, I understood how great JavaScript is and how its features are leveraged by jQuery. The book is small but it gives all the keys to understand and appreciate JavaScript while reading the Definitive Guide felt like reading the yellow pages.

When I want to learn a new programming language, I read a book covering it in paralllel of writing exploratory code. This funny tweet makes me wonder how much the first book I read on a language shapes my thoughts on it.

2nd example: Ruby. I learnt Ruby by reading the pickaxe book and did not find the language compelling. I thought it was a good scripting language, more readable than Perl, but nothing really stood out. Then I read Why’s (poignant) Guide to Ruby and was blown away: I better understood Ruby mindset, loved it and started to write some non-trivial code1.

I am currently “evaluating” two languages: Clojure and Scala. I started with Clojure and read Programming Clojure by Stuart Halloway. I really enjoyed the book (I plan to review it in a future entry), its examples are relevant and well-thought and it gives a good insight to understand Clojure mindset. I have started to write some pet projects with Clojure and really enjoy the experience.

I have also read Programming Scala and I am underwhelmed by the language. It looks like a nicer, evolutionary Java but I do not find it appealing. It may be a fine language but it did not click with me like JavaScript did after reading “The Good Parts” or Ruby after reading Why’s “(poignant) guide”, or Clojure after reading Stuart’s book.
Programming Scala is a good book to learn Scala syntax, etc. but I do not have a better grasp on Scala mindset after reading it. Anybody interested in Scala should read it but I can not say that it helped me grasp what makes Scala so great.

I was teased enough reading Programming Clojure to enthusiastically dive deep into Clojure. The main reason is, of course, the Clojure language itself but a big kudos goes to Stuart and his book which made me wanting to learn more.

This is not a “Scala Vs. Clojure” argument. I plan to add both to my toolset eventually but, in the short term, I will focus on Clojure when I need a functional/concurrent programming language.
This is not specific to Scala, there are other languages that leave me cold. Python is a fine language but it does not appeal to me 2., I prefer Ruby for similar tasks but I can’t objectively explain why it is the case.

The common point of “JavaScript: The Good Parts”, Why’s “(poignant) Guide to Ruby”, and “Programming Clojure” is that they describe well the mindset for their respective languages. I am not interested to write Java code in JavaScript, Ruby or Clojure. I want to understand what makes a language unique, its strengths and weaknesses and how to think in the language. Any book which helps me understand that is a book I wholly recommend.


  1. jmx4r meta code comes straight from Why’s dwenthy.rb. Thank again, Why, for all your contributions. 
  2. Reading Dive Into Python 3 will perhaps change my mind… 

JRuby Cookbook Has a Section About jmx4r

I noticed today that O’Reilly just released JRuby Cookbook. I have a few ideas I’d like to implement using JRuby and I was browsing the table of contents to check if the book could be helpful.

I was pleasantly surprised to see that it contains a section about “Performing Remote Management with JMX” using jmx4r (you can read a preview of the section by expanding it from the table of contents).

I’m obviously biased but I deeply believe that a small library such as jmx4r (less than 200 SLOC for the main file and 1/3 are comments) shows what the combination of Ruby and Java can achieve.
JRuby leverages the strong Java runtime (with its garbage collection and hotspot) and allows to access a wide range of Java libraries with all the strengths of the Ruby language.

For example, in jmx4r case, I extensively use Ruby metaprogramming toolset to dynamically create the properties and methods correponding to the MBean attributes and operations.

There are also other stories which demonstrates what JRuby brings to the table coming from the C-Ruby world.

I’m looking forward to read this cookbook and write some ruby code built on top of the Java platform.

Review of JavaScript: The Good Parts

I admit: I don’t like JavaScript.

I have written and maintained very few scripts and it was a frustrating experience to have them working on several browsers.
However this was many moons ago and I wanted to reevaluate JavaScript after using it in unexpected places (i.e. outside of the browser) like in CouchDB View API or Eclipse Monkey (I already wrote about JMX scripts using Eclipse Monkey).

I was looking for a good book on JavaScript, the language. There are many many books on JavaScript but they focus mainly on JavaScript in the browser and spend thousands pages describing the DOM (please, Messrs. the editors, save the Amazon forest and just print some links to the online DOM documentation…).
I wanted a concise book about writing simple and maintainable code. I also wanted to learn more about the weird syntax constructions spotted when reading non-trivial bits of code, such as processing.js or CouchDB View’s map/reduce.

I bought “JavaScript: The Good Parts” on the strength of the author‘s chapter in “Beautiful Code” and I was not disappointed.
This is exactly the kind of book I’m looking forward to when learning a programming language. It is short (100 pages + 50 pages of appendixes including JSON description) but dense, the sample code are small and meaningful (even the done to death fibonacci and factorial functions used here to explain memoization).
The book does not lose space describing extensively the whole language. It focuses on the subset which is good and proven and do not talk about the edges or the parts which are better forgotten. It really shows how to write code which is both readable, maintainable and elegant.
I’m sure I’ll come back to this book every time I read JavaScript code using some peculiarities of the language that I don’t understand.

After reading this book, I’ve got a better understanding of JavaScript and now sees the good (and even beautiful) parts of it. I have a better appreciation for its prototype-based design even if it is hindered by a class-based syntax.
I also find it frustrating that the JavaScript standard library is so useless (no I/O to communicate with the rest of the world). Of course, the library is richer when the code is to run in the browser or on Rhino (gaining access to the whole Java platform) but, by itself, the standard library is very poor compared to what comes bundled with Python or Ruby.

These are critics of the language. For the book, I’ve got nothing but praises. I recommend it to any programmer wanting to learn more about what is good in JavaScript.

One advice about the code examples: it is much simpler to use Spidermonkey or Rhino than the web browser to run the different scripts and experiment with them interactively.