Javascript vs Ruby Hipsters
Over the weekend, there’s been trouble brewing in the web development world… A kerfuffle has broken out over the lack of semi-colons in the Twitter Bootstrap javascript libraries. Nerd slapfights like these would under normal circumstances not be notable but in this particular case programming luminaries such as Douglas Crockford and Brendan Eich have waded deep into the argument.
The authors of the widely used (indeed we have discussed it on this very blog) Twitter Bootstrap library have chosen to omit semi-colons in their javascript code. Javascript, being a C based language uses semi-colons as a statement terminator. However, the javascript parser is able to automatically insert semi-colons if they have been omitted and it detects a newline. Howerver, in his book Javascript: The Good Parts and in various talks he has given on the topic, Douglas Crockford makes it clear that the semi-colon is a necessary statement terminator. Newlines should not be used in its place due to the likelihood of bugs creeping in. Backing up this point of view is Brendan Eich, who we should point out, actually invented Javascript.
The issue has raised its head on a bug opened on the official Github Bootstrap repository wherein Bootstrap is described as not working with JSMin, minification software created by Douglas Crockford. Commentators say the issue could easily be resolved by adding the semi-colons. Crockford himself comments on the thread, his opening gambit being, “That is insanely stupid code. I am not going to dumb down JSMin for this case.” Lines are drawn, sides taken and insults thrown around.
So why are these developers choosing to use new-lines in place of semi colons? Some claim that semi-colon usage arguments are a form of Bikesheding; concerning yourself with trivial issues such as what colour to paint the Bike shed rather than focusing on more complex and relevant issues. Others argue, and indeed in the comments of the Github thread in question it is stated by the project’s owner, that if you are familiar with javascript you can omit semicolons and rely on the automatic semi-colon insertion. Doing so is in some way a showing of skill, mastery over the javascript interpreter. The omission of semi-colons is also an aesthetic choice. By not using them the code is more readable to Ruby developers. This drive to make the language more Ruby-like led to the creation of Coffeescript and it is understandable that developers might way to use standard javascript in a similar way.
However Ruby developers are also seen as San-Fran livin’, fixie riding, floppy haired hipsters with giant egos who are more concerned with image that substance. Developers who are concerned with making code “beautiful”, as if programming were a medieval art like glassblowing or being a blacksmith. People who wear T-shirts proclaiming them to be “Code Poets”; programming Lord Byron’s. It is unsurprising then to find that Bootstrap is the output of Ruby developers.
Having a C based language overridden by the aesthetics of Ruby can be jarring especially when it runs counter to how it is supposed to be used. Indeed as another commentator states in the thread, “Semi-colonless Javascript is an ego-stroking attempt at rejecting standards for the sake of rejecting standards, not for the greater benefit of the community.” That Crockford’s views are assailed by commentators who’s photos have them posing with teddy bears, oversized sunglasses and ironic haircuts doesn’t dissuade the view of hipster Ruby developers.
The bug has now been closed with no resolution and a lot of acrimony, the debate will, we are sure, continue.