Hacker News new | past | comments | ask | show | jobs | submit login
Underscore.coffee (jashkenas.github.com)
19 points by m0th87 on Oct 7, 2010 | hide | past | favorite | 8 comments



This is the coffeescript version of underscore.js.

BTW, these beautiful documentation webpages are auto-generated with a tool, as pointed out in the underscore.js post: http://news.ycombinator.com/item?id=1767897

There are equivalents for several languages.


Cautionary note: this version is slightly out of date, and needs to be updated to reflect the changes in Underscore 1.1.1 ...


It's probably worth noting that you can just use the original Underscore.js in your CoffeeScripts, which solves the problem with being out of date.

Underscore.coffee is a good demo of CoffeeScript though.


Someone should write a JavaScript -> CoffeeScript converter. Shouldn't be too hard, I might actually do this myself when I get time.


I'm not really a fan of this literate coffeescript. Most of the code speaks for itself, and the English explanation make the code much harder to follow. It's worse than "add one to i" because at least that doesn't take up multiple lines.


I agree that Underscore's functions are simple/short enough that the commentary doesn't add much. However, do you still think that literate-style documentation isn't helpful for more complicated modules like this one?

http://sstephenson.github.com/strscan-js

Or, to take an extreme example -- this one:

http://jashkenas.github.com/coffee-script/documentation/docs...

... where the code is very detail-oriented, and you need the commentary to convey the "what", and the "why" -- while the code explains the "how".


Literate programming is useful, but not when the commentary is "the function createMeAFoo creates me a foo".


Those English explanations are just the comments from the original JavaScript version, put in their own column. If anything, this avoids breaking the flow of the code itself.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: