There has been a lot of discussion about CoffeeScript, pro and con; I am here to tell you why you should use CoffeeScript, or at a minimum give it a shot. I know some of you are looking for any reason not to use CoffeeScript, but I do hope that you give CoffeeScript a chance, especially if you have spent any time writing JavaScript. It also is further validation for CoffeeScript that Rails is including it in future releases.

I would like to preface this by saying that these reasons stem from my own experiences using CoffeeScript with Node.js and for the browser. I personally was skeptical learning CoffeeScript, I felt that I should stick to JavaScript so I didn't unlearn or cause problems understanding JavaScript down the road. Those were totally unfounded fears, and as I explain below, CoffeeScript has only helped. 

 

CoffeeScript is easy to learn ->

Even with no experience with JavaScript, you can pickup and run with CoffeeScript almost immediately. The syntax is very light, removing unnecessary characters and syntax that only waste space. Once you understand the basics, you will fall in love with the more advanced features that make writing elegant code fun.

Using the main CoffeeScript docs are nice, they detail everything nicely with the resulting JavaScript next to the CoffeeScript examples. Check out the always available realtime CoffeeScript translator, this will make it easy to test your code if you are unsure how it translates to JavaScript early on.

 

CoffeeScript will make you better at JavaScript ->

Part of learning CoffeeScript is understanding how it translates into JavaScript. This might not apply to everyone, but going between the two will help you unravel what really is important to JavaScript. Not to mention features available in JavaScript that you might not have known existed, if not for using their shorthand counterparts in CoffeeScript.

 

CoffeeScript is easier to type ->

CoffeeScript's syntax is clean and requires less typing, which means you can program faster. It isn't faster just because it requires less characters to achieve the same result, but with convenient helper features you will be amazed at how many lines you aren't writing. The best example of saving would be this class and inheritence example.

 

CoffeeScript compiles better code than if written by hand ->

All resulting JavaScript code created from CoffeeScript passes JSLint and follows all the best practices that you should be following when writing JavaScript. If you are writing proper CoffeeScript, you are writing better than proper JavaScript. You get all of this with considerably less thought and effort. 

The CoffeeScript command line utility has the ability to run your resulting code through JSLint automatically. For that extra level of ease and security.

 

CoffeeScript is consistent and opinionated, JavaScript is not ->

No matter who you talk to, they probably write their JavaScript differently than you. From someone that doesn't use semicolons, to those that put their commas first. JavaScript is very flexible, and that is a good thing at times, but it can make it hard working with other programmers if there isn't a common style. CoffeeScript is consistent, there is very little variance between straight CoffeeScript, and that is a good thing. You don't have to worry about brackets, parenthesis, semicolons, or even commas most times. Just write code, don't worry about the semantics.

 

You don't have to love CoffeeScript to appreciate it, you con't have to use it to respect it, but you should at least try it before you condemn it. I hope that you will take a chance and at least try CoffeeScript, it won't bite, I promise.