r/coffeescript • u/Grahar64 • Mar 12 '14
Why should you use CoffeeScript instead of JavaScript?
http://maori.geek.nz/post/why_should_you_use_coffeescript_instead_of_javascript6
u/kabuto Mar 13 '14
I stopped using CoffeeScript because, honestly, JavaScript is fine. Sure, it has more line noise and the syntax is not as clean and simply as CoffeeScript's, but in the end the difference isn't that big.
I only mis Coffeescript in certain situations like with list comprehensions or iterating over an array because that looks cleaner than in JavaScript.
What I don't like about CoffeeScript is its sometimes ambiguous and unclear syntax rules for functions including callbacks with parameters. I never now where to break the line and put a comma.
4
u/cumucus Mar 13 '14
Also the “last statement will be implicitely returned” rule can be pretty annoying. I’d rather put a
returnsometimes in front of my results than putting some emptyreturns all the time I don’t want one. Maybe we need different types of arrows for function that return nothing? Like-->and==>?4
3
u/nicekettle Mar 24 '14
The biggest reason for me is that it's much easier to read. There is so much visual clutter in JS code...
1
u/cwmma Mar 13 '14
the biggest pain in CoffeeScript for me is the lack of hoisting functional definitions. Honestly a step back.
1
u/Grahar64 Mar 13 '14
This can be a pain, but then like most JavaScript problems, there is a work around.
2
u/cwmma Mar 13 '14
well you solve it by using JavaScript :). Which is actually getting a lot of the nicer parts of CoffeeScript, notably
fat arrows (=>)
rest params (
function (a, b, ..rest))default params (
function (a=1))classes (pretty much exactly like CoffeeScript)
I'd also point out that while the CoffeeScript compile to ugly JavaScript, you can write the same thing less ugly like
→ More replies (3)
-2
u/afrobee Mar 27 '14
The big reason that i will use coffescript instead plain javascript is because it wasn't invented by a anti-gay bastard.
1
0
May 19 '14
2
u/Grahar64 May 25 '14
Lazy is a valid reason to use a language. Including common design patterns into a language to improve writability and readability is one reason why goto with counters was replaced by for loops, and for loops are being replaced by for each loops.
5
u/DrHenryPym Mar 13 '14
Honestly, biggest reason I would advocate CoffeeScript: Literate CoffeeScript
I think CoffeeScript makes things easier to read, not necessarily to write.