7 ms·
Node.js stdlib ported to CoffeeScript (6,501 additions, 15,896 deletions)
- jashkenas 15y agoDarn, this looks like auto-generated CoffeeScript. Much less interesing...
- amasad 15y agoIts definitely generated. Just compared some files from the output from http://js2coffee.org http://js2coffee.org Its not even funny anymore.
- LoneWolf 15y agoTo be honest, I do not like the idea. I do not use node much, only played with it a little. Now about CoffeeScript, I CANT read it, hurts my brain pretty bad, and I fail to see how can it be good.
- ntime 15y ago"hurts my brain" == "don't understand" *I use vanilla JS.
- djtriptych 15y agoIf you really used vanilla JS you would have used the typed equality operator :P. === fo' life.
- maratd 15y agoNo, he wouldn't have. If you use === everywhere, you're wasting bandwidth for the extra character. Use === only when the type matters and is likely to be different. 99% of the time, it's when you want to distinguish between undefined, false, 0, and null.
- ZenPsycho 15y agothat's a false economy since you must also include however many bytes it takes to explain in a comment that you used == on purpose, and not as a typo- to warn future maintainers not to switch it to === when they run it through JSLINT.
- maratd 15y agoYou put comments in code? I place all comments in a separate markdown file.
- ZenPsycho 15y agoI normally don't. Unless I do something silly like use == that could be taken as a mistake.
- vertr 15y agoCould you share a link that describes this? I'm having trouble finding anything about it.
- maratd 15y agoJust take a look at how Mootools or Node.JS takes care of their documentation. Same principal. There is no need for comments/documentation to muck up code.
- leptons 15y agoPut comments in code, and then run your code through YUI or similar to strip the comments and whitespace when deploying.
- leptons 15y agoIt takes more effort to understand the nuances of code written using significant whitespace than it does with a C style language where statements are clearly broken up for you. There is less room for ambiguity, and less room for user error.
- bullshite 15y agoMaybe the problem lies in your brain, and not coffee script. You aren't a super genius. Humble yourself, admit you suck ass, and try to make yourself better
- LoneWolf 15y agoThen tell me why is coffeescript good. Because I fail to see it
- lepht 15y agoI'd be curious to see whether there's any substantial performance differences
- nas 15y agodiffstats are misleading since it looks like he stripped at least 20 lines of comments from each file (license blurb). If Coffescript really did remove that much code I would seriously consider switching. Most research has shown that bug count is pretty heavily correlated to source line count.
- jashkenas 15y agoIt tends to reduce LOC from JavaScript by about 30%-50% ... nothing near this as extreme as this auto-generated version.
- shuzchen 15y agoWhile I don't disagree about the point regarding the relationship between line count and bug count, I'm very wary of this move because they still haven't solved the issue on how to debug CoffeeScript with all your error messages being reported back to you in terms of the compiled Javascript.
- azakai 15y agoYes, until there are proper stack traces in CoffeeScript, it's very hard for me to adopt it for anything. A project I work on has a small amount of CoffeeScript, and debugging problems in that component is the hardest part of the whole project.
- nas 15y agoThat's an implementation detail though. Although it's a lot of work to fix, it's not insurmountable. You would need your development browser to support Coffescript natively. It's not really a serious problem if IE7 generates a Javascript back-trace, right? 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.
- ricardobeat 15y agoYou don't need to support CoffeeScript natively. The answer is simple and is called source mapping: the output code carries comments that map each line to a line in the source file. This will also work for LESS and any other transpilers. Work is underway since August to implement it in WebKit (http://peter.sh/2012/01/css-selector-profiler-source-mapping-and-software-rendering/ http://peter.sh/2012/01/css-selector-profiler-source-mapping...) and Gecko (https://wiki.mozilla.org/DevTools/Features/SourceMap https://wiki.mozilla.org/DevTools/Features/SourceMap - the intern has gone back to school, really?)
- limeblack 15y agoAlthough it is a nice joke, CofeeScript has several issues. 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/javascriptinasimpleway.png 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.
- jashkenas 15y agoTo play devil's advocate: Does JavaScript have "several issues", in that it allows you to write your first example like this? https://gist.github.com/1567793 https://gist.github.com/1567793
- limeblack 15y agowhich 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 simple with anonymous function creation.
- jashkenas 15y agoFYI, function application wraps rightward to the end of the line, or the end of the block, so: foo -> bar 'foo', -> 'bar' Means: foo(-> bar('foo', -> 'bar')) But in any case, you wouldn't write it like that.
- limeblack 15y agoTelling the user to write something in two different ways, depending on the argument being passed, isn't simple. The point is an ending delimiter would greatly benefit CoffeScript. Although CofeeScript certainly has its perks, anonymous function creating isn't simple then Javascript.
- ejames 15y agoIt's a joke commit, with auto-generated CoffeeScript from a conversion tool. 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.
- leptons 15y agobecause, coffeescript is a joke
- thezilch 15y agoThe title, of this submission, does not include the fact that thousands of the deletions have very little to do with a port. All licensing is removed. All comments are removed. Significant carriage returns are removed. As well, while LoC is cool to count, promoting line removals that only include an end-of-block ("}") is not, at all, interesting or helpful. 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.
- mbq 15y agoGreat, now go and convert Linux kernel to OOC; I'm sure Linus will merge it right away.
- dkasper 15y agoThis kind of trolling should not be on Hacker News, and I definitely can't believe it got 70 points. Might be time for some more Erlang articles...