Hacker News new | comments | show | ask | jobs | submit login
Why Do All the Great Node.js Developers Hate CoffeeScript? (procbits.com)
25 points by roh26it on Nov 30, 2012 | hide | past | web | favorite | 55 comments



I've been accused of writing linkbait-y titles in the past, such as "CoffeeScript isn't a language worth learning."

https://github.com/raganwald/homoiconic/blob/master/2011/12/...

So I suppose I'll have to just say that looking at the article itself and argue the content rather than the packaging. So here's the premise: A bunch of great JS developers aren't also CS developers.

Possibility #1: Correlation == Causation. Writing CoffeeScript rots your brain and makes you unfit for writing great Node.js code.

Possibility #2: Writing great Node.js warps your brain such that CoffeeScript is unpalatable.

Possibility #3: Writing great Node.js code means you're very comfortable with JS itself and your tool chain, and thus you look askance at any switch.

I'd say that both #2 and #3 are far more likely than #1. Neither of them imply that you shouldn't use CS today if it seems appealing.


I'd give 3 more possibilities:

#4 pretty much the only advantage of CoffeeScript is saving a few keystrokes, not worth spending time on

#5 most of your day is still spent reading javascript, the mental overhead of switching between JS and CS all the time makes it unappealing

#6 using javascript makes for writing better javascript libraries than coffeescript


#4 is most of the point of using most languages. Languages that operate at a higher level 'aka. saving keystrokes' generally do so by offering higher level constructs.

(a) -> (b) -> (c) -> ((x) -> (y) -> (z)) is readable and understandable in coffee script the same is not true for javascript, but it's just a 'few extra keystrokes' to do the same thing in Javascript.

Same thing in mathematics, it's just a few extra keystrokes to express 2 ^ 3 ^ 4 ^ 6 ^ 7 in basic addition, same thing with calculus and algebra.

The point is valid in the trivial case but as soon as you start looking at saving a few keystrokes as a 'expressive power' then it makes a lot of sense to use a language like coffeescript.

Once you start using the expressive power of a higher order language, it's an order of magnitude more keystrokes in the less expressive language.


#4 pretty much the only advantage of CoffeeScript is saving a few keystrokes, not worth spending time on

Well, I suppose you could also say that the reason I might use Ruby over Java is to "save a few keystrokes". I'm exaggerating to make the point that shortcuts for common tasks are important.

- String interpolation (`"foo#{bar}baz"`)

- Existence unary operator (`foo?`, `foo ? "bar"`)

- Splats (`(foo, bar...) ->`)

- Comparison chaining (`10 < foo < 20`)

- Loops and comprehensions (`x() for x in ["foo", "bar"]`)

- Destructuring (`[foo, bar] = items`)

- Ranges (`num for num in [1..10]`)

- Array slicing (`items[3..5]`)

- Object properties (`for own key, value of object`)

I think these are all substantive improvements to JavaScript, not even taking into account readability-improving sugar like post-conditions.


#5 is probably true for many people. #6 might be true, might not. Amplification of your ideas would be welcome.

#4 needs some clarification. If you're making a global statement, then you're contradicting my experience and the statements of many CS users. Agree or disagree, clearly it's "debatable" and not axiomatic accepted fact.

Or you might be saying that for some developers, including the quoted node developers (and possibly yourself), there are insignificant benefits. I listed the possibility that the node developers saw no significant return on investment, so if that's what you're saying, then we agree.


> Or you might be saying that for some developers, including the quoted node developers (and possibly yourself), there are insignificant benefits.

Exactly, I read your comment in this style (which seems to have been correct according to what follows my quote) and decided to use the same. These were not intended to be understood as the absolute truth brought down from the mountain.

Although some of these points do roughly match my thinking (if I'm going to learn a not-JS-but-compiles-to-it, I'd rather use something drastically different which can bring significant gains — e.g. Roy or ClojureScript — or build -my-own via SweetJS than limited syntactic sugar)


I'm not sure I qualify as a "great Node.js developer" but for me it's #5 all the way.


Yup #4 for sure. Unnecessary layers of abstraction/context switching increase complexity and debugging difficulty and are nice to avoid.


I find that CS introduces very few layers of abstraction in the true sense of the word "abstraction." Even its classes are just syntactic sugar for existing semantics.

My (mild) knock against it is that it doesn't introduce any new abstractions. No special sauce for continuations or promises, for example. But that is obviously a two-edged sword, it eschews new semantics by design.


I've personally noticed a huge productivity boost by switching to coffeescript. It's anecdotal, but there's something to it I'm sure.


Great node.js developers are writing libraries, not application code, and they see a difference: libraries are abstractions that try to build upon as little abstraction as possible, and attempt to integrate with as many 'things' as possible.

CoffeeScript's advantages - clarity and concise code - are outweighed by the feeling of building on an abstraction, and narrowing your contributor base. This feeling may be increasingly inaccurate: a lot of people write coffeescript, it's pretty well integrated nowadays.


we write plenty of application code actually, all of us listed there I'm sure, we just dont give a shit about the "features" coffeescript "adds"


> 'we just dont give a shit about the "features" coffeescript "adds"'

I'm not sure why you're claiming to speak for the other nine developers listed in the post.

It's a good point that tmcw makes. Plenty of developers, including Jeremy Ashkenas (creator of CS), write their open-source library stuff in vanilla javascript while hacking away with CoffeeScript for other things which don't rely on community contributions.


and here I was trying to be an apologist and be nice :)


I don't get it. Look at Jade, Stylus ... pythonesque isn't it. The same arguments that are made against CoffeeScript certainly can be argued for those sugar syntax alternatives of HTML and CSS respectively. Some will argue ad nauseum for not using semicolons and then hate on CoffeeScript.

I've had no problems debugging or understanding CoffeeScript and while I'm not at the level of a Jon Resig, I can more than hold my own with Javascript. CoffeeScript is just syntax and generally safer than plain Javascript. It will declare vars for you if your forget. It will use an optimized for loop. It will put a wrapper around code to minimize leaks ...


The main difference there is with stylus / jade you basically have two states, tag and non-tag, rule and property, so it's much less ambiguous. Once you get into lots of logic in either however they similarly ambiguous, there's no doubt about that


TL;DR: Several high-profile Node.js developers seem not to have used CoffeeScript for any of their public projects (unless you count forks). In addition, some unspecified expert Node.js devs (perhaps the same ones, perhaps not) made an unspecified joke involving CoffeeScript on a podcast. Therefore, all the great Node.js developers hate CoffeeScript.

I'm not arguing what the article seems to circle around to near the end - that CoffeeScript is worth trying - but its nominal premise seems a little shaky. Perhaps those developers simply feel as I do, that Javascript syntax is fine and there's not that great of an incentive to switch. I actually like braces and semicolons, and I definitely prefer function literal syntax to arrow syntax.


In the end, its just syntax. Some like the python/ruby-esque mode and thus go for coffee.


In the end it's another syntax, another compiler, several new plugins for your editor, another dependency, a bunch of new abstraction, another unproven technology, another black box, etc. It's not so simple, the choice shouldn't be made lightly.


I used to really enjoy writing in CoffeeScript, but lately I've been finding that it's much more difficult to read after the fact. As TJ put it -- "word soup".


I love CoffeeScript. But then, I am well-versed in JavaScript. People who don't understand scope, lambdas, prototypes, etc. should stick to JavaScript, as CoffeeScript obscures some of that. You really should understand what's going on behind the scenes.

Which makes it all the stranger that experienced JavaScript developers seem to avoid it, while less experienced ones embrace it.

My main gripe with CoffeeScript (there are a couple, but here's one) is code organization/readability when a method takes multiple functions as arguments.

    foo ->
      bar()
      baz()
      quux()
    , (error) ->
      throw error if error
That does look a bit odd, and you run into these a lot when you're using caolan/async. You can avoid this by avoiding anonymous methods, but with so many callbacks in Node.js that is probably less readable.


You can assign the functions to variables and then make the function call in one line. Adds one line of code and a lot of readability.


Yes, but please see my last sentence. With so many callbacks in Node.js, it can make it just as difficult to follow.


I agree that function calls like that can get weird in coffee - I like to write them like this, which i think turns out to be a little more readable:

  foo(
    ->
      bar()
      baz()
      quux()

    (error) ->
      throw error if error
  )


Nodejs and Coffee are surely a nightmare. I've tried using async to improve code readability but it still doesn't fit well with coffee.


I really love CoffeeScript. Javascript has some great programming concepts within it and CoffeeScript makes these more elegant and easy to use. The reduction of needless syntax is also a boon to me.

In fact, I've been using CoffeeScript to postprocess data from molecular simulations (supercomputer output). It's about 3x less code than an equivalent C program and requires a lot less thinking so I can get things done quicker. But I tend to use CoffeeScript in a functional style (which in my opinion is the best language paradigm for handling a lot of data).


There are "systems developers" and there are "applications developers". The two groups often use different tools, so JavaScript vs CoffeeScript isn't much more surprising than C vs C++ or Win32/COM vs .NET for that matter.

Systems developers provide services for other developers; generally they want to minimize dependencies. It doesn't make sense to write foundational tools in CoffeeScript unless all the clients of those tools will be written in CoffeeScript as well. Otherwise you're just adding complexity to their projects and making them harder to debug.


systems developers? You mean those guys who wrote V8 in C++?)


You mean those guys who wrote C++ in C?


Because CoffeeScript causes a cognitive dissonance by a) Attempting to address Javascript's shortcomings. b) Shows how much more comprehensible a well-designed language could be. c) Shows what one smart guy with a deeper CS knowledge and good taste could do.)


Personally, I would want to understand JavaScript before moving on to some abstraction. The official Node.js documentation is written in JS, etc.. Then, once I am totally capable with JavaScript, there just isn’t a great incentive for me to learn another language to code on top of the same environment. I’m very happy with JavaScript. CoffeeScript has become an instant turn-off to me, and I think this sentiment is common in the community. If someone asks for help in the IRC channel, I just can’t offer a thing. And usually no one can. I’ve seen many calls-for-help that fell on deaf ears because few people are willing to learn CoffeeScript for assisting a fraction of the community. Why do I hate CoffeeScript? Because I like helping people. :( This is my personal history, and you may notice that I am totally ignorant of any benefits that CS may provide by way of being more concise, or linguistically harmonious.


Quote: "Having defected from Rails, I love CoffeeScript."

This is a common reason I've heard. Here's the bottom line, CoffeeScript is not javascript.

Suppose you want to speak Japanese but only know English. Google comes out with Translate 4.0 that does realtime translation on the fly. Great! Now you can speak Japanese, right? No.

Most of the devs I've personally interacted with that like Coffeescript are conversely bad at javascript. Admittedly this is anecdotal and only based on my personal experiences.

Learn javascript. Get a book, read some tutorials. Quit trying to squirm around just because closures make you nervous.


This is like analyzing some of the huge Java projects out there, noticing they don't use Scala, and deciding everyone hates Scala. Particularly with public projects, you want them as easy to use and simple and require as little as possible to get into them. Adding an extra language translation will not help with those things, especially if the language is not as common as the one it translates into.

I don't particularly like Java compared to some other options, but I still code in it most, simply because of the huge number of libraries and developers who use it. It's very difficult to write any big project by yourself, which means you need others, which means you need to not use obscure languages and other technologies that prevent working together. I much preferred writing for Linux PDAs than I do writing for Android smart phones, but if I did that, no one would use my stuff. :)


I like CoffeeScript. It makes writing some things in JavaScript a little bit easier and maybe even a little bit faster.

However, I don't like _using_ CoffeeScipt. It immediately shuts out the other 85%+ of JavaScript users who aren't familiar with CoffeeScript from reading and understanding my code.


I dislike using coffeescript mainly because the language is too flexible. Being able to optionally omit a ton of syntax has led to some annoying problems that aren't obvious at first glance. This ambiguity is exacerbated by the way javascript is typically used (chained methods, nested lambdas, etc).

The other gripe I have is that debugging it is a pain in the ass since errors that come back reference the javascript code, not the coffeescript. Apparently this is a problem being worked on but it's still irritating.


But because nesting is a pain-in-the-ass in coffeescript, I've become used to breaking down code into chunks and invoking functions which ultimately makes code more readable solving many other problems.

I do agree on the debugging aspect. I always have to go back to the compiled javascript to understand errors. Can you please point me to solutions being worked upon in this regard? Open source?


One of the things provided by the CoffeeScript Redux project is source mapping, which enables line-to-line correspondences for debugging.

https://github.com/michaelficarra/CoffeeScriptRedux

http://ryanflorence.com/2012/coffeescript-source-maps/


CoffeeScript Redux project seems interesting. Thanks!


I've found the second case is actually the fix to the first; any funky compiler interpretation of my source is immediately visible in the .js code.

But overall I agree; I wish they'd fixed the JS quirks that they did, allowed indentation instead of braces, added their lambda syntax, and stopped about there. It goes too far on optional syntax and functional features that are gradually being added to JS anyway.


I'm not a great node developer, but I personally don't like CoffeeScript for the same reason I don't like UI interfaces for Git. I'm never sure what it's going to do.

Yes, I could go look at the output, or go really learn it, but if my goal is to produce javascript then it's just another leaky abstraction on top of something that isn't that hard to do by hand. If my choices were CoffeeScript or ASM, then I'd choose CoffeeScript in a heart beat.


I don't truely see enough benefits for coffeescript. 99% of the eco-system uses vanilla JS and i would like to stay in one "language" as much as possible.

In general i don't really feel comfortable with code-generating layers that abstract away what i want (and need) to know. I want to look into the Chrome Devtools, see "line 23 in bla.js" and correlate that to the source in my editor. Same reason i don't use all that less/sass/haml etc. etc.


I doubt that the CoffeeScript-haters would accept any compile-to-js language. Maybe it's language stockholm syndrome. ;)

But for me, JavaScript's shortcomings are far worse than CoffeeScript's.


I don't care about any language that isn't natively supported in the browsers.

Not all browsers have support for source maps, and sometimes you really need to debug browser specific behaviours without having to debug generated code along the way.

Additionally in most teams I work on, it is often the case that besides myself no one even knows what CoffeScript is.

CoffeScript just adds more code to debug without any real benefit.


I'm not a very experienced Node.js developer, but I have taken the time over the last couple of months to learn how to use it. I find working without CoffeeScript to be much more productive.

Then again, that may change when I get a lot more comfortable using Node. At the moment I just prefer to know exactly what's going on under the hood.


The reason I have not learned coffeescript yet is because I want to truly understand javascript. I feel that learning something more portable is the way to go. As I understand more javascript I think about what problems CoffeeScript is trying to solve.


I'm learning the variable scope of javascript very thoroughly because it is powerful. I don't want to be hindered by shortcuts eliminating some of that power/understanding.


Without trying in jsfiddle, what does this alert;

var i=3; function x() { alert(i); var i=5; } ​x();​

and why is this powerful? I agree with you mostly, but I don't like this 'feature'.

Edit: hoisting yes, but why, besides compiler optimization is it more powerful for the programmer than if it would not do hoisting, or, why is it in a modern language like JS?

Edit1: I'm not in favor of coffeescript I used Javascript most of the time during my work day, I was just seriously wondering, if not for low level optimization why it would be a problem to have global scope until local is defined.


Undefined, that's hoisting.

I think it is dirty, but the point of the var statement (and your hoisting example) is that you implicitly imply the variable scope. In Coffeescript, you just do an assignment and it will be function scope if it (the variable) doesn't exist in any parent scopes? That seems dirtier to me and dangerous.

If you are awesome and namespacing and keeping clean/modular/maintainable code, Coffeescript may work great.


Someone correct me if I'm wrong, because I'm not a pro by any means: var statement allows for implied variable scope and avoid variable collisions from parent scopes


undefined, of course. What's confusing about it? The function hoisting?


The hoisting yes. I didn't say it's confusing. I said I don't like it. And more particular I don't see why it's powerful and why the logical result (being that it takes the global i until the local is defined) would be less powerful.


Javascript is great if you don't do oddball things with it. Nobody can rightly deny that there is a ton of potential to do stupid things with javascript. I'm sure someone could write out a line of [other language] code that is quite the head scratcher, and works as defined in the spec. If coffeescript works as a nice complete syntax re-do for you, that's good but you have to learn two programming languages in that case. I prefer raw js, auto-linted to help highlight any potential stupidity. In the supplied example, the var at the end of the function would be caught by the linter indicating that it leads to bugs and there is no good reason to do it - so don't.


I question the premise.


I just love JavaScript


Jeez, there's the word "hate" again, second time this morning. What a bunch of drama queens we all are. Not particularly caring for a language or disagreeing with the premise for its creation is "hating". OK. And here it's even worse, because the author elevates these developers to the status of "great" and then paints the fact that they do not care for CoffeeScript as "haughty".




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: