3 ms·
> CoffeeScript simply has better syntax than plain js in every way, and any js developer will be more productive using it. That's a pretty bold claim. Have any
by awj 15y ago
> CoffeeScript simply has better syntax than plain js in every way, and any js developer will be more productive using it.
That's a pretty bold claim. Have any examples to back it up? Most of what I've seen of coffescript (note: I haven't looked hard) seems to be relatively similar syntax with fewer characters or fixing JS gotchas that many developers are familiar with.
Both of these are useful things, but they don't make a 100%+ productivity boost in my mind.
- Cushman 15y agoList comprehensions. Distinct 'of' (property) and 'in' (value) operators. Bind a function to current 'this' with =>. Nothing winds up in global scope unless you mean it. Use reserved words as property names. Existential operator and assignment. Always use '==='. Everything is an expression: value = switch value when 1 then one else whatever Closures. do (value) -> #value is wrapped in a closure The 'class' macro. And that's just off the top of my head. Yes, it compiles to JavaScript. You could write all this by hand. It would be a waste of your time-- CS writes safe, efficient, readable code faster and better than you do, every time. Look harder.
- te_chris 15y agoPeoples' obsession with CS having the class macro is weird to me. Seems like laziness more than anything - once I grokked JS's protoype object model I've found it to be ridiculously powerful AND I got to learn a cool new programming abstraction at the same time. All the rails guys I know are going gaga over CS but I just don't see the point as I like and can be efficient in JS.
- Cushman 15y agoI can't speak for anyone else, but I treat the class macro as pure shorthand. I understand implicitly that "properties" in a "class" are being assigned one at a time on the constrictor's prototype, and frequently use that knowledge for metaprogramming. You call it laziness; I call it nicer syntax. I understand that puts me in a small boat. In my opinion, people shouldn't use the class macro without knowing what it really does. Actually I'd extend that to say people shouldn't use CoffeeScript at all without an understanding of the JavaScript it compiles to, just as you shouldn't use C without an understanding of the assembly it compiles to... But that's probably wishful thinking. It wouldn't be an improvement for those people to write assembly (or raw JS) instead.