Live data from Hacker News

Why I Don't Use CoffeeScript (2011)

oscargodson.com

11–20 of 23 posts

Re: Why I Don't Use CoffeeScript (2011)

#11
Why I use Coffeescript: It increases my productivity. I know Javascript, I've written a lot of Javascript, I don't need warts removed for my own protection.

I write Coffeescript because it generally results in ~30% less actual code over Javascript, and the reduced boilerplate substantially reduces cognitive overhead when trying to grok a piece of code that I (or my team) wrote six months ago. I get stuff done with it, and I could get stuff done with Javascript (and often do!), but...why spend effort I don't have to in order to solve my business problems?

The abrasive, condescending theme that Coffeescript is only for noobs who couldn't otherwise hack it in Javascript makes my eyes smoke from rolling so hard.

Re: Why I Don't Use CoffeeScript (2011)

#12
> Even if you've never programmed before the 2nd example would make sense.

That's not actually true. Functions and return values are themselves concepts that must be learned and are not inherently more intuitive than coffeescript's lambda style. I would agree if the author means this: "Even if you've never programmed in javascript, but have learned the basics of another of the most common languages, the second example will make sense."

This might seem like a nitpick, but the whole argument is along these lines. It boils down to "I don't use coffeescript because it is less familiar to me than javascript", which is totally fine, but different people are familiar with different things.

Re: Why I Don't Use CoffeeScript (2011)

#14
post #6

I wholeheartedly agree. While Coffeescript to some is a must-have in every project they work on, it comes with a higher learning curve than Javascript itself. I understand we as developers are always trying to find ways to do things faster, less typing and better productivity as well as eliminating error, but Coffeescript is not the silver bullet that many make it out to be. I actually had a Coffeescript experience a…

Not to mention, ES6 adds a lot of the more useful stuff from CoffeeScript without most of the problems. All too often I have seen developers using CoffeeScript run into the unfortunate implicit return and awful readibility of objects problem when trying to debug code - I often either point it out off the bat, or I use the CoffeeScript compiler to figure out what they had and what they intended. That is extra unnecces…

I'm curious what issues you've run into with implicit returns. I haven't traced a single problem to implicit returns in many years of using languages that have them.

Re: Why I Don't Use CoffeeScript (2011)

#16
The post is pretty subjective and doesn't sound like it comes from someone who spent much time w/ coffeescript.

If you're gonna hate on it, there are much more significant things to hate on:

- whitespace are significant in a hard-to-spot way, e.g. `foo () ->` vs `foo() ->`

- it adds a lot of potential for ambiguity and the need to revisit syntax in existing code when editing it, e.g. going from `foo(1)` to `foo(1).bar(2)` in js doesn't require deleting text in existing code. In CS, going from `foo 1` to `foo(1).bar(2)` does (and have fun grepping for the variations.) Another example: take untog's promise example and add a reject callback.

- accidental implicit returns and variable shadowing bugs do happen and they're not very easy to trace because they break code elsewhere instead of where the problem is

- Coffeescript doesn't provide a systematically superior environment (e.g. compare to compile-time type checking in Typescript or immutability-by-default in Clojurescript), but being a transpilable language, it does create significant downsides (need for a file watcher/build system, limit hireability/hinder initial productivity for non-CS devs, etc)

Re: Why I Don't Use CoffeeScript (2011)

#17
post #7
post #4

Interesting article, I like some of the points the author makes. I did want to bring up use for(var i=0; i<10; i++) rather than a for .. in loop. But isn't a for in loop for objects, while the first for example is only for arrays? I don't think you can reference an object's keys with an incrementing counter (unless the object is specifically designed like this?

I suppose you could use the first example with Object.keys ... var keys = Object.keys(myObj); for (var i = 0; i myObj[keys[i]]; }

Object.keys is incredibly slow and you should never use it, for in loops are far quicker.

Re: Why I Don't Use CoffeeScript (2011)

#18
post #6

Earlier quoted context omitted.

Not to mention, ES6 adds a lot of the more useful stuff from CoffeeScript without most of the problems. All too often I have seen developers using CoffeeScript run into the unfortunate implicit return and awful readibility of objects problem when trying to debug code - I often either point it out off the bat, or I use the CoffeeScript compiler to figure out what they had and what they intended. That is extra unnecces…

I'm curious what issues you've run into with implicit returns. I haven't traced a single problem to implicit returns in many years of using languages that have them.

Not me so much as others - it's a very common problem I've seen when debugging other people's CoffeeScript code. CoffeeScript is a bit of a different situation than other languages since with other languages, it's the norm (i.e. Ruby) - however, with JavaScript, it is not something inherent in JS, so when people jump from JS to CoffeeScript, there is a disconnect.

Re: Why I Don't Use CoffeeScript (2011)

#19
post #3

After everything, CoffeeScript is for people who hate JavaScript. It isn't, though. It's for people who want to use a variant of JavaScript with less syntax sugar, which is exactly what the start of the post says. And the example of a single function does make it look like CoffeeScript is a waste of time. However, I love it when working with promises. What used to be: promiseFunc() .then(function(a) { return doSometh…

For correctness and to make the comparison more fair, the compiled CS is actually: promiseFunc() .then (a) -> doSomething(a) .then (b) -> doSomething(b)

Why would I be reading the compiled code?

Re: Why I Don't Use CoffeeScript (2011)

#20

The author gets a lot of stuff wrong, and the loudmouth attitude doesn't help either. > -> vs function Starts off taking issue with the sort triviality he later admonishes the language for solving in other areas. You don't have to start your function bodies on the same line. > But, more than all of this what bugs me is the fact it's a completely transpiled language mostly for syntax sugar. What an awful reason. What'…

I sometimes use CoffeeScript for personal stuff, but have mostly moved back to plain JavaScript even for that. And yet I find this one of the silliest articles about why not to use it. You've explained why very well.

The main reason I moved back to plain js is that: 1. I can't really get used to significant whitespace. But that's mostly just taste. 2. CoffeeScript is a bit too ambiguous for me at times. It makes me feel the same way Ruby On Rails does. But that might also just be a personal preference.

That said, I really miss a lot that CoffeeScript offers. Can anyone recommend a similar and ideally popular project that offers much of what CS has (brevity and comprehensions being among the main things) without the significant whitespace, and without the ambiguities?

Post reply on HN