4 ms·
I found CoffeeScript to be a pain to work with. CoffeeScript added some useful features, like destructuring assignments, and some syntax sugar for objects, loo
by partycoder 9y ago
I found CoffeeScript to be a pain to work with.
CoffeeScript added some useful features, like destructuring assignments, and some syntax sugar for objects, loops, etc... but it also made some choices that in my opinion are bad:
- Making delimiters optional like parentheses, brackets, semicolons... in addition to implicit return statements: makes programs hard to read if abused. Makes code formatters get confused and corrupt your code.
- Not being able to distinguish an assignment from a variable definition: causes identifier typos to become new variables.
This implicitness makes programs error prone in ways that are hard to verify and work with. Plus, needs to be transpiled and you will need sourcemaps.
In the end, the benefits are not worth it, even back during the time it was created.
- ddebernardy 9y agoAnother pain is (was?) debugging. This might have changed since but back when I tried and rejected using it. But back then, if you had an error at line X it would report the (compiled) JavaScript line rather than the CoffeeScript line - meaning you'd need to figure out which CS code generated what line of JS code in order to hunt down and fix issues.
- teh_klev 9y agoWould source maps not help in this case? http://gunnariauvinen.com/using-source-maps-with-coffeescript/ http://gunnariauvinen.com/using-source-maps-with-coffeescrip...
- jononor 9y agoYup sourcemaps works fine for this, at least in browsers
- DiThi 9y agoIt works with node --inspect as well.
- partycoder 9y agoMost likely you will like to set a breakpoint at the entrypoint. You can do this with --inspect-brk rather than --inspect. Then you can see all debugging sessions in Chrome using chrome://inspect
- DiThi 9y agoThe first problem is easily avoided with a few style guidelines. If a feature exists it doesn't mean it must be used. You can configure CoffeeLint to avoid confusing constructs. The second problem didn't turn out to be as big as I thought. I was bitten by it about a couple times a year, and every time it was symptom of too long functions or too many closure nesting. Transpiling and source maps are not a problem. Small changes in my code takes 200 ms to recompile with source maps, with webpack in watch mode (projects are ~20k lines). And when I start a new project I just copy the webpack config from the previous one (with cli switches for several features).