Search

Pony Foo

Ramblings of a degenerate coder

We don't want your Coffee

(27 comments)reading time: , published

An open letter to the CoffeeScript community.

You can follow the discussion on Hacker News.

This rant probably also holds true for TypeScript, and similar. Heck, even asm.js. I know asm is awesome in theory, but have you actually tried going through a piece of code written in that? It's garbage, and you aren't really supposed to do that to your everyday code base either.

Now, don't get me wrong, I'm completely fine with you sipping your fancy coffee yourself. My problem lies with you spilling coffee on everything you do, or trying to force-feed coffee to everyone else. Your coffee is becoming an infectious disease, and you need to stop it from spreading. Languages like CoffeeScript represent a problem to the community as a whole not because the language is inherently bad, but because you assume everyone else understands that non-sense.

What? It's not non-sense, it's beautiful! It's JavaScript.

Newflash. It isn't JavaScript, it just compiles down to it. Stop trying to subjugate people on StackOverflow by answering their JavaScript questions with CoffeeScript code. Stop trying to get JavaScript help posting Coffee code we don't understand.

coffee-script.jpg

The problem isn't in the language itself. While I may not like CoffeScript personally, I celebrate the diversity, like pretty much everyone else. The issue is with people like yourself, who post things on the web as if everyone knew how CoffeeScript works. Sure, it compiles down to JavaScript. We get that. But we're not going to learn your language, and it looks funny.

I don't have to tell you things are bad, everybody knows things are bad. It's like everything everywhere is going crazy, so we don't go out anymore. We sit in the house and slowly the world we're living in is getting smaller, and all we say is "please, at least leave us alone in our living rooms".

So, I want you to get up now.

mad-as-hell

Did you know that some companies are in fact turning their back on Coffee, just because people don't really know the language? The problem Discourse encountered was simply that they weren't getting as many contributions as they expected simply because their JavaScript was obfuscated behind Coffee, reason enough for them to flip the switch and move away from CoffeeScript. The problem is clear: people who know Coffee should know JavaScript if they want to write decent code. The opposite doesn't really hold true, the rest of the universe has no reason to learn Coffee, and those of us who don't buy into its perceived value are left out in the cold.

I'm not even getting into the which one's better? debate. I don't really like the syntax but then again, I don't care that some people do, either. Besides, others have typed pretty long articles on the subject. After all, the first non-procedural language I came upon was Visual Basic, which has the sameish "human-readable" syntax style that we find in CoffeeScript, with gems such as one isnt two reminding me that once upon a time I, too, relinquished code quality in favor of blindly telling my compiler On Error Resume Next, an obscure construct in VB where it acted as if every single line was wrapped in a try/catch block. Oh, the joy of blindly and naively debugging code back then.

The problem with the child-like syntax is that it hides too much, making the code nearly impossible to read for un-caffeinated fellows such as myself. Not that we want to. This isn't the case of all languages that compile to web-ready languages (HTML, JS, CSS).

Jade, for example, produces clean HTML that simply uses CSS selectors, in a syntax something very similar to what you might know as the Zen Coding. When you compare Jade with the exceedingly verbose nature of HTML, or XML, the benefits start becoming glaringly obvious.

Here's some Jade

ul#crocodile-items
  li(ng-repeat='foo in bar')
    div {{name}}
    div.details
      div
        span Description
        span {{desc}}
      div
        span Price
        span {{price}}

The HTML took me quite a bit longer to type by hand

<ul id='crocodile-items'>
  <li ng-repeat='foo in bar'>
    <div>{{name}}</div>
    <div class='details'>
      <div>
        <span>Description</span>
        <span>{{desc}}</span>
      </div>
      <div>
        <span>Price</span>
        <span>{{price}}</span>
      </div>
    </div>
  </li>
</ul>

The pros to Jade start piling up when we take into account things like inheritance, mixins, JavaScript, and, well, the fact that you won't be forgetting to close tags anymore.

In the case of Coffee, though, it's as if it was the other way around. What the hell is happening in the JavaScript that gets compiled? I've no idea. To me, it's a black box. I don't like black boxes. They're black, and cube shaped. And that's about all I know about black boxes, they don't tell me anything about what's going on under the covers. Writing JavaScript code directly means we have full control over what we are doing, and that has precious value. One last thing. How are you going to incorporate ES6 when it comes around? To my knowledge, it'll break CoffeeScript as you know it. That kind of sucks. It means you'll either be stuck in a language that can't exploit all of the latest features in JavaScript, or you'll have to change tons of code in order to be back at square one. Me? I'd rather not be boxed into feature lockdown by the same language that's pretending to help me write better code.

My suggestion to you isn't even to stop using CoffeeScript, but to be more thoughtful of those who don't know anything about your pretty language. Always compile your code down to JavaScript before posting a question to StackOverflow, or replying to a blog post. You might even learn things about JavaScript itself, too.

Comments on Hacker News.

Comments(27)

Qawelesizwe Mlilo

Hi Nicolas, man I love your blog and your JS skills. I couldn't agree more (with all due respect to CoffeeScript ofcause).

Maybe I missed your point. But the fun thing about this post is that you can replace "JavaScript" with "Assembler" and "CoffeeScript" with "C" and "2013" with "1973" and it will be the same. You should watch "The Future of Programming" by Bret Victor.

Nicolas Bevacqua

The point is mostly about some CS people being inconsiderate when posting answers written in CS to JS questions on SO, or asking JS questions but showing CS code, very much like when someone posts a question or answer in spanish, or french.

The JS/ASM CS/C comparison doesn't make any sense. ASM is completely unreadable to most mortals. JavaScript is just not that pretty to those who don't like it, this is apparently the case of some Ruby and Python developers.

Jeffrey Gilbert

ASM.js is meant to be generated by other languages. It's not meant to be read. The point of it is for programatic performance gains, not readability. It's math based. So unless you read nothing but math fomulas and arrays all day, the point is moot.

And coffeescript is its own language, so if there are going to be complaints about it, they should be directed at the language and its caveats, not a rant about hating preprocessor languages because they're not pure enough.

David Hanson

"This rant probably also holds true for TypeScript" <<<< For the record it doesn't.

Johan Steenkamp

Agree 100% - if I see coffeescript I just move on. As you say - I like to know what's going on. Nice contrasting with Jade.

Patrick Mesana

I understand what you mean, but I don't agree completely on your comment about black boxes. Javascript is a black box in a way, abstracting lots of memmory management for you, it is not alway implicit what the language does for you but it doesn't seem to bother you. V8 also does a lot of complicated hidden improvements. I don't see coffeescript compiler doing very complicated stuff, you can learn about it in 1 hour or less. Anyway, my point of view is the language is useful at application/testing level, maybe less for apis or libs where you need a better grip on the code you want to expose.

Leonid K

well, since javascript is the new assembler, no wonder people HAVE to use something more sane :)

legomushroom

Great post! The question is - do we have to use preprocessors or libraries when we trying to explain and share our source code. The way people use Jquery in their posts and answers is pretty much the same. Abstractions and code length it gives to us is really valuable. And if jq is just common library, the syntax of cs will almost become the syntax of js in es6 shortly. I will definitely agree with you about SO - it is not very polite to answer with jq/cs on js questions. Thank you!

题叶
  1. Pasting compiled code is considered impolite, since there's already a neat version of code, so I perfer pasting both versions when asking on StackOverflow, or if there's someone pointing that project uses JavaScript than CoffeeScript, I would drop the CoffeeScript version.

  2. I learned CoffeeScript before JS, meanwhile I think CoffeeScript is so simple that JavaScript programmer knows it, especially who people know Ruby will find CoffeeScript dead simple. Your case is strange to me.

  3. CoffeeScript's maintainer rejected a bunch of features to keep CoffeeScript same with JavaScript. So please don't see CoffeeScript like TypeScript.

notatestuser

So there are a couple of things I've inferred from your post

  1. you don't like coffeescript because some other people don't know coffeescript
  2. you don't like coffeescript because it compiles into code you don't understand

I don't see either of these being a problem with the language itself or its use in projects. Like jade, its use tends to increase productivity because you're able to make use of features like list comprehensions

Talysson de Oliveira Cassiano

Men, he just wants to say that CoffeeScript it NOT Javascript, so it's not polite to answer a question about JS with CS as if they were the same, as if JS programmers always use CS in their projects. Just it, he's not saying that he doesn't like it because it's hard (it's not !).

I totally agree with the post !

And about the comparison jQuery-CoffeeScript: it's not the same thing, jQuery uses JavaScript sintax, CofeeScript don't, a JS programmer easily understands jQuery, the same is not true about CoffeeScript.

Alexey Astafiev

A black box is actually red or orange. So it's easy to spot them.

Cory Wright

A forgotten truth, indeed.

social

Awesome article. Those are exactly my thoughts when i would stumble onto any variation of coffeelike snippets anywhere. The most unbearable is when you start spending time looking for something very specific only to find out there's only a stupid unreadable snippet of coffeescript around.

notatestuser

http://js2coffee.org/#coffee2js

Nicolas Bevacqua

@notatestuser that just goes to show how easy it is for CoffeeScript users to translate their code before posting a CS answer to a JS question

Tony Brown

never was a fan of coffee-script, I think it's not as readable as javascript and I hate the fact that it was being forced on you. this is a good read as well http://bit.ly/156CHrS

Frans Krojegård

While I respect your right to not like CS, this post is off-putting and not constructive.

Just because you can't read it doesn't mean it isn't legible.

I also respect the right to answer with CS on a JS question. I don't think I've done it myself, but if I take time out of my day to answer one of your questions shouldn't you be happy I made an effort at all? Downvote if you don't like it. CS is mostly JS. Can't really think of anything that's CS specific enough to be illegible to a decently seasoned programmer. If a newbie receive that answer maybe that isn't optimal of course.

Comparing JS and CS to Jade and HTML is a decent comparison. Yes, there are differences, but one is a programming language and one is a markup language, big fucking whoop that it's not exactly the same thing.

joe.minichino

Jython and Java both compile to bytecode. Next time I answer to a Java question I'll write my answer in Python, what the hell.

The post is not an anti-CS crusade, it's specifically about CS users being very confused about the legibility of their answer to JS coders.

And by the way, the amount of people that assume that JS coders have knowledge or familiarity with Ruby is amazing. All Ruby has done for JS is to bring in a bunch of kids thinking omitting semicolons is hip.

Iván Vega

Man, I love CS and JS both, and I understand and agree with your point about answering a JS question using CS. However I think that point is kind of lost with the rant. Just my 2 cents.

Max Hodges

After all, the first non-procedural language I came upon was Visual Basic

wtf, VB is a non-procedural language?

credibility alert

Neidhardt Buell

VB is considered an Even Driven programming language unlike its direct predecessor QBasic which is procedural.

Max Hodges

I think the author's analogy between Visual Basic and CoffeeScript reflects gross ignorance of both Visual Basic and CoffeeScript.

...Visual Basic has the sameish "human-readable" syntax style that we find in CoffeeScript.

uh, not really. The opposite is true actually. Which is more human-readable:

#javascript
if (opposite) {
number = -42;
}

#Coffeescript
number = -42 if opposite

I, too, relinquished code quality in favor of blindly telling my compiler On Error Resume Next, an obscure construct in VB where it acted as if every single line was wrapped in a try/catch block. Oh, the joy of blindly and naively debugging code back then.

Structured error handling using the Try block is a relatively recent innovation, appearing in the first versions of Visual Basic.NET. Visual Basic 6 and earlier versions used a more line-oriented syntax sometimes called Visual Basic Classic Error Handling. In fact you can still use both styles in the same program, although not in the same routine.

Any programming language feature can be an "obscure construct" if you don't properly understand it. As far as debugging is concerned, Microsoft had been long ahead of others with their sophisticated IDE. I'm not sure what the author is comparing it to, but debugging VB with stack trace tools, watch window, and code stepping was and still is quite a joy indeed.

Michael Robinson

I think you'll find that a large proportion of the programming community find the former more readable.

Programming languages cannot be human languages, and the opinion of many is that they shouldn't try.

Michael Theriot

The former. This is the first time I've seen conditions placed after what should occur.

Neidhardt Buell

I would agree that the former is more readable. I think it has a lot to do what has become the defacto standard, which sets my expectation of how the language will express itself. I don't expect to see a logical operator after an assignment without a visual clue that something is different with this language.

Pony
Foo
Pony
Foo
Pony
Foo