Posts tagged with "programming"

The real problem with OO is taking it too far

March 18th, 2012

I just finished watching this talk by Jack Diederich (Python core developer) – somewhat flamebait-ishly named “Stop Writing Classes”. In his talk, Jack shows, through various examples, how introducing a class just for the sake of it actually makes the code harder to read and maintain. While reflecting on the talk, I realized that the [...]


Writing applications versus frameworks

February 22nd, 2012

At work, since I mostly write web applications I usually end up consuming frameworks rather than writing them. So, I have been reading a lot of framework-ish code on GitHub lately, and it has turned out to be an awesome source for finding clever tricks, patterns and coding conventions. Writing frameworks requires a slightly different [...]


First element of an object in JavaScript

January 17th, 2012

This one will go into the bag of clever hacks which you should use sparingly, if not ever. Given an object like this: var obj = { a: "foo", b: "bar", c: "baz" } Here’s how we get the “first” property of the object/dict: for (var first in obj) break; console.log("First property is: "+first); We’re [...]


ECMAScript harmony features in Chrome Canary

December 26th, 2011

The latest Canary build of Google Chrome allows you to unlock some new features from ECMAScript Harmony. However, they are disabled by default, so to enable them you have to type about:flags into your address bar, and turn on “Enable Experimental JavaScript” which is found right at the bottom of the page. Now, you have [...]


Abusing Scala’s anonymous argument

December 7th, 2011

In Scala, you can use the underscore (_) to refer to an argument you are lazy to name. val numbers = List(1,2,3,4) numbers.map(2 * _) // List(2, 4, 6, 8) You can go a step further. val numbers = List(1,2,3,4) numbers.map(2*) You can completely omit the _ as well, because * is actually a method [...]