Monday, 17 September 2012

DropBox Coffee Script Conversion

I was just reading coverage of DropBox switching to using some CoffeeScript rather than JavaScript in some of their code base, I was insenced enough with confusion over the coverage to post a comment on the thread... Let me give yout he gist...

The folks over at DropBox have changed to this CoffeeScript code in an effort to "simplify" the code... Least this is one of the major reported reasons for their switching out to JavaScript, they also mention removing bugs... and less size/RAM being used.

Analysing this waffer thing argument however and there's a glaring problem... First of all, CoffeeScript "compiles"* down to JavaScript, so there's nothing CoffeeScript does which you can't yourself achieve in JavaScript... If you end up with smaller code from the output of CoffeeScript then you could simply have written your JavaScript better yourself...

Then there's the argument about CoffeeScript being simpler, and easier, to maintain... I argue that CoffeeScript is just someone deciding that they don't like the C style language formatting of JavaScript and opting for a different style, something which looks rather like HASKEL to me... gah... or Occam... Or a myriad of other languages which don't use braces and semi-colons, you can check it out on their site.

Now consider that most programmers worth their salt know a C style language, its more common and arguably more comprehensible, given JavaScript code they could get by... Given CoffeeScript... its rather alien, take for example the JavaScript for a function:

square = function(x)
  return x * x;

Now, look at the CoffeeScript...

square = (x) -> x * x

I find the second to be too abstract, square equals an x in brackets (which indicate parameters input) pointing at x times x... What the hell does that actually mean?

Where as the first bit... the square equals a function that takes an x... and that function returns x times x... its a bit less alient, a bit less "haahoo we know sucks to you" in the coding community parlance.

The article says it all, my comment, if it gets published says more...

No comments:

Post a Comment