Skip to main content

CoffeScript vs Script# vs JavaScript, and why it’s funny to me

Greg Roberts

Greg Roberts

Greg Roberts

I’ve seen a lot of buzz around CoffeeSecript lately, mainly because it’s now bundled with Rails 3.1 and there’s been a lot of positive and negative reactions to it. Let me just start out by saying I’ve written a good amount of JavaScript code, and while I’m mainly a .NET developer I’ve played around with other frameworks so I’m not totally ignorant of what is out there.

Here is the problem I see with most JavaScript code. It’s really hard to do it right. There are enough bad parts in the language, that it takes probably a good 6 months practice and learning to really grasp all the good parts. Even then I think most people, myself included, end up writing a weird mix of object oriented and functional style goo that it becomes really tiresome to get good. It reminds of when I first tried to play racquetball, I was a tennis man for years, and racquetball seemed like an easy transition, but the style of swing and racquet were different enough that it was apparent the better I got at racquetball the worse I would be at tennis and vice-versa. I think some people pick it up really well, but for others they either don’t take the time, are scared, or just don’t know any better.

This is where something like CoffeeScript comes in. It’s promise is that if you write your code with us than we’ll convert to professional quality JavaScript. The problem I’ve always had is that you have to learn a new language/tool to get good at another language. What I find sort of laughable is that the same people that are loving CoffeeScript are the ones that scoff at using Script#. Both are basically doing the same thing, taking one language and compiling it down into another. Then it really becomes a question of, which language would you rather write your abstracted JavaScript in C# or CoffeeScript? The answer to this probably depends on what you are more comfortable with, but my main point is the two are conceptually the same.

refactor compile error

VS#

coffee

Obviously the tooling behind C# is way more advanced, and all the good things that come with that like refactoring and intellisense. The other benefit is that you don’t need to learn a new language (assuming you know C# already). The main benefit I see with CoffeeScript is that it exposes the “Good Parts” of JavaScript a lot better than C# does, but if you know those good parts wouldn’t you prefer to write in plain ole JavaScript anyways?

So here is my takeaway, abstractions aren’t always a bad thing, as long as what is produced is of equal or better quality than you could do yourself. With that in mind, I think both options are viable and will be for a long time to come, so go out and support the one that fits your style the most.

https://github.com/NikhilK/scriptsharp

https://github.com/jashkenas/coffee-script