79 points · by jashkenas · 14y ago · 46 comments
About 3,700 deletions come from files that were erroneously replaced by empty files. Another 1,400 or so are from removing the license comment at the top of the files, and I'd imagine stripped comments throughout the code add a bit more.
The actual compression ratio seems to be about 20-25%, then. It's likely that idiomatic CoffeeScript, rather than generated CoffeeScript, would be somewhat shorter, but probably not by a drastic amount; I'm no JavaScript guru but the Node.js source doesn't strike me as verbose to begin with.
It seems to me that CoffeeScript is in some ways an attempt to make you write using only - in the words of Douglas Crockford's book title - "Javascript: The Good Parts". The most representative test of its success would thus be rewriting a bad library or tool into CoffeeScript and seeing if it makes the inner badness come to the surface where you can deal with it more easily. If you're already writing disciplined, well-organized JavaScript, than there's no reason to stop.
The important thing is if Coffeescript really does significantly reduce line count and by extension bug rates. I'm not sure it does, generally syntactical sugar doesn't have that effect.
I hope it does. My life seems nicer when writing Coffeescript vs JS.
Work is underway since August to implement it in WebKit (http://peter.sh/2012/01/css-selector-profiler-source-mapping...) and Gecko (https://wiki.mozilla.org/DevTools/Features/SourceMap - the intern has gone back to school, really?)
Its not even funny anymore.
In short, the diff in LoC is just snark to pull at the strings of those that will correlate LoC to bug counts.
What are the advantages of porting Node.js to CoffeeScript? Node doesn't deal with the DOM or browser incompatibilities, which are the stronger reasons to port.
I could explain why omitting an ending delimiter is an issue, or how easy it is to add a new line or space, but the image does a decent job.
http://img856.imageshack.us/img856/306/javascriptinasimplewa...
Now guess which of the three Javascript examples is generated by.
foo -> bar 'foo', -> 'bar'
The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter.CofeeScript isn't pretty very clear.
Also you didn't account for the widely-deployed technology of paren/bracket matching.
foo -> bar 'foo', -> 'bar'
The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter.CofeeScript isn't simple with anonymous function creation.
foo -> bar 'foo', -> 'bar'
Means: foo(-> bar('foo', -> 'bar'))
But in any case, you wouldn't write it like that.There are horrible ways to write a lot of code, especially in whitespace based languages. What does petty comparisons like this bring to the argument?
*I use vanilla JS.