11

I am a freelancer and I earn my bread and butter by helping others write better java-script code. I have good experience with most of the JavaScript frameworks around.

I am wondering if it is worth for me to invest time in learning coffeescript. Who should learn it and who need not ?

Trevor Burnham
  • 744
  • 6
  • 4
Eastern Monk
  • 339
  • 3
  • 8
  • This is a fairly vague question. Who should learn it? Whoever wants to. It's just a matter of preference, it ends up being translated into JS anyway. –  Apr 30 '11 at 16:04
  • 1
    Related question: http://programmers.stackexchange.com/questions/72569/what-are-the-pros-and-cons-of-coffeescript/ – Trevor Burnham Apr 30 '11 at 18:15
  • Professionally speaking, start learning stuff when you see enough want ads you'd be a fit for unless you happen to really dislike the thing enough and you have choices of course. – Erik Reppen Nov 26 '13 at 06:04

4 Answers4

8

First, Coffeescript is not terribly difficult to learn. I was able to become quite comfortable with it over only a few days, and my Javascript was very amateurish - I'm sure that if you're talented with Javascript, it'll be much quicker for you to pick up.

As for whether it's worth learning, I think that's a question that only you can answer. I doubt that it will be as helpful for you as it was for me - coming from Ruby, I found Javascript's syntax to be incredibly messy, and I would constantly introduce errors by dropping a semicolon here or a parenthesis there. Coffeescript made it much easier for me to write working code. If you're already comfortable with writing Javascript, though, I can see how you might find it cumbersome.

My advice would be to take a quick look through the CoffeeScript docs, and try to decide whether you would personally prefer your code looking the way it does now, or the way the example code does there, and you'll have your answer. Just don't be scared away by the learning curve - it's not very steep at all.

7

My own experience is that learning CoffeeScript helped me to better understand JavaScript. Of course, I'm an extreme case—I was a mediocre JavaScript programmer, and I decided to write a book on CoffeeScript: http://pragprog.com/titles/tbcoffee/coffeescript

So with that bias out of the way, I'd say: Everyone who isn't an absolute expert on JavaScript (and wants to be one) should learn CoffeeScript. It gives you a fresh perspective on what "the good parts" of the language are. Brendan Eich, the creator of JavaScript, has repeatedly praised CoffeeScript for giving JavaScript an elegant syntax without obscuring its semantics.

Will CoffeeScript help you directly in your freelance work? That's harder to say. There certainly aren't as many jobs asking for CoffeeScript code as for JavaScript code (though it never hurts to ask "Is it OK to use CoffeeScript for this job?"), but then, there aren't nearly as many competing CoffeeScript freelancers either. Of course, you may be able to get away with submitting compiled JavaScript, as long as the hirer doesn't have specific code style requirements. CoffeeScript output is pretty readable, though of course not as good as expertly hand-written JavaScript (assuming the expert knows how to write for humans...).

Finally, I'd note that CoffeeScript has a great community that you can draw on for help. One of the perks of new languages is that, generally, only smart programmers learn them (see Paul Graham's essay "The Python Paradox"). So while there are fewer CoffeeScripters than JavaScripters, you may find it easier to get help with hard problems by having friends in CoffeeScript-land.

Trevor Burnham
  • 744
  • 6
  • 4
3

Coffeescript caters mainly to those who cut their teeth as programmers with Python or Ruby. I, for one, learned with python, and even though I've used other c-like languages such as c#, php or javascript itself, I always found their syntax cumbersome, verbose and ugly. It's annoying having to deal with all those curly braces, semicolons and line noise.

Coffeescript borrows the best ideas of these languages while keeping javascript's "good parts" untouched. It simply adds a better, more expressive syntax on top. There are things that take several lines of code in javascript that can be expressed with one liners in coffeescript, and those are way more intuitive, clear and expressive.

Examples: How do create an array of numbers from 3 to 10?

myarray = [3..10]

How do you create another array whose items are the previous ones multiplied by three?

newarray = [i*3 for i in myarray]

Just try doing it in plain javascript, and you'll know why Coffeescript is god send for many of us...

Luis
  • 31
  • 1
0

I made the conversion from JavaScript to CoffeeScript about 6 months ago and I love it, there are so many places where the syntax just makes life a little easier.

For example you can de-structure an object in an assignment so I just wrote some code like this

func = ({io: io, el: el} -> ...

So you pass it an object and it breaks it apart into its parts, I really love coffeescript

Zachary K
  • 10,433
  • 2
  • 37
  • 55