3 ms·
coffeescript fell out of use because ES6 brought like 90% of the benefits of cofeescript and added a few more things. One of the few things that coffeescript st
by DanielHB 4y ago
coffeescript fell out of use because ES6 brought like 90% of the benefits of cofeescript and added a few more things. One of the few things that coffeescript still had going for it was the different syntax that a lot of people like (identation-based blocks, no curly braces, etc)
As always pragmatism won and ES6 thrived, but Coffeescript still had a few things that ES6 didn't have. My favourite feature is "everything is an expression" so you can do something like this:
eldest = if 24 > 21 then "Liz" else "Ike"
see:
http://coffeescript.org/#expressions http://coffeescript.org/#expressions
this comes from Lisp and makes a lot of things easier. Obviously this was not implemented in ES6 because it would break compatibility and there is also some problems with implicit returns that made the feature a bit weird
I wonder if a syntax like this for JS would work:
const eldest = if (24>41) { escape "Liz" } else { escape "Ike" }
with "escape" working like a mix of "break" and "return". But even then this is likely to cause incompatibilities
- Yahivin 4y agoHopefully I can fill in that last 10% of ES6 which is something I really missed from CoffeeScript. A lot of the features taken from Coffee were "almost as good" and that grinds me down after a while. Basically if I can get a reimagined successor to CoffeeScript making decisions based E20xx as it is today then I'd be quite happy.
- esperent 4y agoWhat about: const eldest = 24>41 ? "Liz" : "Ike";
- flappyeagle 4y agoThis is ugly and hard to read compared to trailing if. They’re about the same for a one-liner but if you have anything more complex, Ruby style trailing if is far superior.
- esperent 4y ago> This is ugly and hard to read compared to trailing if. For short statements like the examples given here, it's not ugly and it's easy to read. Whether it's easier/harder to read than trailing if depends on how familiar you are with each syntax. I don't think either is superior in this example. I agree ternaries are not suitable for long complex statements. However, I don't think trailing if is suitable for long complex statements either. I've generally only seen it used in simple cases.