We Don't Use CoffeeScript Ever

CoffeeScript is a very popular alternate syntax for JavaScript with very little benefit compared to plain JS. There are few reasons to use it and a great many reasons why it’s pointless. This is a totally off-the-cuff, opinion based piece on why CoffeeScript is totally useless and stupid. If you don’t like rants, then read this and tell me why I suck or don’t read it and tell me why I suck anyway.

Why CoffeeScript?

Apparently with CoffeeScript you avoid polluting the global namespace (finally, no more clobbering that damn jQuery and how many times have you accidentally defined your own String() implementation only to find that pesky JavaScript already has its own!) and it’s really pretty and it reminds you of Ruby. So, that’s totally a reason to avoid writing plain JavaScript forever, yuck!

But in all seriousness, most developers I’ve talked to have like 4 reasons and 4 reasons only as to why they prefer CoffeeScript and they all basically amount to “because I understand Ruby”. What? How does Ruby fit into all this? Well first, let’s go over the actual reasons 99% of developers cite for CoffeeScript being superior to JavaScript:

  1. No more polluting the global namespace! (Bullshit – this should rarely happen and is too fucking easy to avoid if you’re really that concerned about it)
  2. The Syntax (whitespace is so great, its like I’m writing my jQuery in Ruby)
  3. The Syntax (functions make so much more sense… because I’m that asshole who forget a 6 character long return statement and blames the language for being difficult)
  4. The Syntax! (I can make classes in a functional language! Who cares how JavaScript Object prototypes actually work, just make the syntax pretty and then give me a gun, point it at my foot, and write a tutorial on how I can pull the trigger so I can complete the process of shooting myself in the fucking foot)
  5. The Syntax!!!! (ZOMG is like Rooooby so much! So its better, here’s a list of reasons that aren’t reasons, I’m super hipster kthxbai)

That pretty much sums it up. No more polluting the global namespace and pretty syntax. JavaScript can get messy and it often does. I won’t deny that. But this idea that making the syntax pretty fixes everything is bullshit. CoffeeScript creates more work than its worth.

Polluting the global namespace? Well, then just don’t do that. Know the language well enough to not clobber any built-in types and know what variables your libraries expose and you’re good to go. If you’re developing a library for consumption then wrap it in a closure. How hard is it to do this?

1
2
3
(function() {
  // do something - you're safe in here from the scary global namespace
})();

The syntax? Really? You mean that you can write JavaScript in Ruby and that’s cool. Fuck Rails for ever promoting this. To be a decent developer you need to be familiar with the languages you need to do your job. CoffeeScript does for JavaScript essentially what jQuery did for it – developers learn the library or the special syntax but never the language itself. So now rather than having a JavaScript developer, you end up with a CoffeeScript developer or a jQuery developer which is only a partial JavaScript developer. This reminds me a lot of one of the reasons I don’t like Rails (I mean, I like it but it also does some bad things) – developers learn Rails and then call themselves Ruby developers. Give them a task to do in Ruby without Rails and they’re lost. They’re like “where’s Rails”? Sometimes a developer has their head so far up their own asshole that they actually think Rails is Ruby. That they’re one and the same. Now, newbies have an excuse. They’re new. But this is the kind of bullshit I’ve seen from “professional” developers handing out resumes where they list Ruby as a skill and asking for $60k to start as a junior developer.

Why not CoffeeScript

CoffeeScript does make the syntax nicer and cleaner. I would actually use it if it wasn’t such a pain in my ass. One problem is has is that you need to go through extra steps to use it. If you work on a project that uses CoffeeScript you need to have some task to transpile that CoffeeShit to JavaScript. You may say that’s no big deal but then you start mixing CoffeeScript with JavaScript in a project with a mixture of developers who like it or vendors who use it for an important library. If you need to work with both, there’s a bit of a burden on you as a developer because you then need to switch contexts. Sure its all JavaScript in the end but there’s still mental overhead when you’re switching from one syntax to another.

I also don’t buy the global namespace argument. That just sounds like something people heard from developers who were more skilled than them in actual JavaScript and now they’re out there parroting this line as if they gave a shit before. It’s just intellectual masturbation.

I use LESS to compile my stylesheets in just about every project I’m involved with. The ideas behind LESS and CoffeeScript have similarities. So why would I be okay with one and not the other? Because to use LESS you really need to know CSS. You can’t just learn LESS and never look at CSS and still get by as a front-end developer. LESS gives me the ability to write CSS in a more efficient way. It adds features that CSS just doesn’t have and then does all the work of making sure my variables and mixins get put in the right place and compiled to neat CSS. CoffeeScript by comparison is a one-to-one syntax switch. There isn’t any additional feature that CoffeeScript gives you that JavaScript doesn’t have. It’s nothing more than a different syntax. The ony exception to this may be CoffeeScript’s syntax for defining classes. On that point, it does add value.

CoffeeScript annoys me. After thinking about it some more, I think what really annoys me are some of the developers who use it. In that respect I suppose what I’m really saying is “I hate looking at shitty code and shitt advice regardless of the language”. So, whatever. Everyone needs a good rant sometimes.

Front-end development, Web development

« Simple API Authentication with Authorization Headers in Sinatra Friends don't let friends auto-generate docs »

Comments