2 ms·
"CoffeeScript may require fewer tokens, sure, but not 10 to 1 fewer." True, but I find that its real power is in not forcing me to remember all sorts of crazy-
by aaronbrethorst 14y ago
"CoffeeScript may require fewer tokens, sure, but not 10 to 1 fewer."
True, but I find that its real power is in not forcing me to remember all sorts of crazy-ass stuff that's only relevant because JavaScript, as a language, is just sort of batshit crazy.
Case in point: I'm doing some work right now that requires me to use JavaScript[1]. Today, I was writing your typical 'is this variable undefined or not?' if-clauses:
if (typeof foo !== 'undefined') { bar(); }
Obviously, I don't do this enough, because I ended up having to look the stupid thing up instead of just knowing it ("I know I have to use === for equality; is the equivalent 'not-equals' version only two equals signs or three?", and so forth).
In CoffeeScript, in comparison, I'd simply write:
bar() if not foo?
It takes a lot less mental energy for me to remember the second version than the first.
Also, if I had a nickel for every time I've had to write var that = this... Anyway, suffice it to say that CoffeeScript may not be an order of magnitude more expressive, but it's cheap enough to get up and running that its benefits are well, well worth it to me.
[1] It's an iOS app that has a critical component built into a UIWebView, and there is absolutely no way to make this stuff native, seeing how it's rendering HTML. I guess I could rig up some awful build phase voodoo that would compile my .coffee files, but that sounds ridiculous.