r/javascript • u/xDinomode • Dec 27 '15
help What's the point of CoffeeScript?
I'm reading a tutorial on PouchDB and like always I run into CoffeeScript. What's the point of it? I've used it before for like 5 minutes and found it useless.
28
Upvotes
43
u/Silverwolf90 Dec 27 '15
Nowadays not much. But it played an important role in evolution of the current javascript ecosystem. I would not start a project with it, just use ES6 and Babel for any transpiling needs.
34
u/pje Dec 27 '15
It's for people who enjoy languages like Python, Haskell, and Ruby, or who are functional programmers at heart. (i.e., think of programs primarily in terms of functions).
ES6 has stolen many of its good bits, but there are still plenty of things CS has that ES6 doesn't. Some CS strengths:
Most of CoffeeScript's advantages are primarily expressive: they allow a developer more flexibility in how a particular operation is presented, in order to emphasize the code's intended function over its form.
(The flip side, of course, is that more expressive languages -- by their very nature -- give people more freedom to express shitty things as well as masterpieces. But that's always the price of freedom, and not just in programming languages!)
32
u/[deleted] Dec 27 '15
how far we've come, that this is a discussion that we're actually having
coffeescript had a huge influence on the evolution of javascript, and at one point had significantly more features than vanilla js. but with babel and es2015 (and onwards) it's outdated.
some people still use it because they like the syntax but most projects moved away from it awhile ago
21
u/third-eye-brown Dec 27 '15
I use it heavily. I like:
Clean syntax
Everything is an expression (this is huge)
Variable declaration happens automatically
Cleaner function syntax and this binding
Null soaking operators
Destructuring
Default args
Allows incredibly expressive, terse, highly functional code. That being said, most people seem unable to read it easily so that's a negative.
12
u/x-skeww Dec 27 '15
It has pretty much outlived its usefulness. Even in terms of keypresses it loses against languages with better tooling like TypeScript. And, well, CS' tooling is pretty bad. Even with plain ES6 you'd be way better off.
I recommend to go with ES6 or, if you like things like type annotations, decorators, async/await, enums, and some duct tape for ES3/5 option objects, give TypeScript a try.
6
u/wmil Dec 28 '15
There's less of an argument for Coffee then there used to be. But here's one cool feature ES6 can't match...
Transpiles to
Checking for properties that may be missing where zero is a valid value is still surprisingly tricky in JS.
17
u/chrissilich Dec 27 '15
It's for people whose bracket keys are broken.
2
u/[deleted] Dec 28 '15
I started to use CoffeeScript on top of Angular1.4 recently and looks tough. Has anybody followed CS+Angular stack. Any comments on positive side.
2
u/[deleted] Dec 28 '15
Most people I know who use it, use it for the class key word.
They're coming from more oop languages, and struggle without it.
I wouldn't use it personally.
2
u/troorl Dec 28 '15
It was great before Babel/TypeScript/Elm arrived.
2
u/seg-fault Dec 28 '15
5 minutes is not enough time to evaluate anything.
-1
u/penagwin Dec 27 '15
For me it is one simple reason. It looks pretty.
-3
u/TotesMessenger Dec 27 '15
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)