I was thinking about learning CoffeeScript some time in the future. In the mean time, Google came out with Dart that seems to do what CoffeeScript does.

Google says:

Dart code can be executed in two different ways: either on a native virtual machine or on top of a JavaScript engine by using a compiler that translates Dart code to JavaScript. This means you can write a web application in Dart and have it compiled and run on any modern browser.

Does anyone know advantages and disadvantages of learning Dart or CoffeeScript?


Update on the status of Dart, Feb 28, 2012

Google is planning to integrate Dart into Chrome browser. As of now, Dart programs can run directly on the Dart VM in Chromium.

link|improve this question
25  
Neither. Be brave and learn "vanilla" JavaScript. – c69 Oct 10 '11 at 19:17
2  
If you are going to start some time in the future, better think about it when you are ready to start. xkcd.com/927 – Sundeep Oct 12 '11 at 18:49
Has anyone ever checked out Aikido language? It seems like the appropriate direction for what the goal was of Dart: aikido.sourceforge.net – anonymous Nov 22 '11 at 5:15
3  
The OP did not suggest that she/he didn't already know "vanilla" JS. Not a very helpful comment. – Glen Ford Apr 15 at 20:48
feedback

migrated from stackoverflow.com Oct 13 '11 at 6:20

This question came from our site for professional and enthusiast programmers.

8 Answers

up vote 84 down vote accepted

Learn Javascript, use CoffeeScript, check out Dart.

Learn Javascript

  • The best way to learn (and debug) Coffeescript
  • Dart is similar enough to JS but far less common. You will come across more JS than Dart.
  • To understand why CoffeeScript exists, and how Dart differs.

Use Coffeescript

  • CoffeeScript is out there in projects already, so there's community and experience.
  • CoffeeScript might come up at work sooner than Dart (esp. with Rails).
  • CoffeeScript is nice!

Check out Dart

If you understand Javascript, and use CoffeeScript, and have checked out Dart, you'll be in a good position to judge which hammer is best for the task. Most JS/CS knowledge should be transferrable to Dart, the other way around would be more difficult.

I love opinion pieces :D

link|improve this answer
9  
Good call on use vs learn :) – Ricardo Tomasi Oct 11 '11 at 5:30
1  
This is an excellent response. I totally agree. – Squeegy Oct 11 '11 at 18:18
5  
+1 This is one of the best answers I've ever seen on StackOverflow. Good job! – Brian Genisio Oct 12 '11 at 1:38
+1 for "Learn Javascript". JavaScript is not evil, and should be embraced. Yes there are things like CoffeeScript that makes JavaScript "nicer" to work with, but knowing "raw" JavaScript will help immensely. – Wayne M Oct 13 '11 at 14:33
1  
dart: putting the java back into javascript (not really a good thing) – Lavinski Nov 22 '11 at 6:24
feedback

This is subjective question... but...

Personally, I like how succinct CoffeeScript is. Dart looks more like Java to me, which makes it less appealing. I am fond of the significant shortcuts that CoffeeScript provides such as lambda notation, optional curly braces and key/value notations.

Honestly, though, I think CoffeeScript and Dart are just steps in a much bigger movement... to bring any language to the browser. We already have compilers that will take pretty much any language to JavaScript but the development story is still pretty crappy without browser support of some kind.

CoffeeScript and Dart will push the browsers to support debugging of other languages and build an ecosystem around other languages. Once that is solidified, I think we will move away from CoffeeScript/Dart and move towards our language of choice.

So, for the time being, find the language that suits you best and go forward with it. For me, it is CoffeeScript.

link|improve this answer
1  
Many great answers on this thread, appreciate your long term outlook on the topic Brian. – Mark Essel Oct 11 '11 at 6:20
feedback

CoffeeScript still is Javascript with prototype based objects, its intend is to extend and improve upon Javascript.

Dart is not Javascript. It's a completely new language which only relates to Javascript in that it has compiler to Javascript. Googles long-term goal with Dart is to make all browsers include a new script-engine that directly runs Dart, the crosscompiler to Javascript just is a placeholder for the real thing till that happens.

Choosing one over the other is making a bet on whether or not Google will succeed with Dart. As an alternative to CoffeeScript Dart can only be inferior because it doesn't support the Javascript object model.

link|improve this answer
Saying Dart is a "completely new language" seems disingenuous to me. It is similar enough in syntax that I'm sure large chunks of javascript can work without change or with only minor changes. – rob Oct 10 '11 at 17:18
@rob: But it is a completely new language. CoffeeScript translates directly to Javascript. Whereas Dart has the option if you want to compile to Javascript. It's just a cherry on top, the meat of the language is the language itself, run on it's own VM. – Sergio Tapia Oct 10 '11 at 20:23
3  
Sorry, but saying things like "As an alternative to CoffeeScript Dart can only be inferior because it doesn't support the Javascript object model" is a complete bullwash. Any Turing complete language can be mapped to any other Turing complete language and any respective differences in the programming model are irrelevent in face of competent implementation – Roland Tepp Jan 16 at 11:20
Your comment would be a lot more convincing if you were writing your Eclipse based applications in C++. – Patrick Jan 17 at 20:52
feedback

I'd vote for Coffeescript because it is already popular, has a simple syntax, and is the good parts of Javascript. Dart is unproven and may never see wide adoption.

(Even if it turns out that Dart overtakes Javascript, they'll probably just have Coffeescript compile to Dart instead) :)

link|improve this answer
feedback

It's worth noting that Coffeescript is not a "whole new language" as someone said above. Coffeescript can be seen as an alternative syntax for javascript. Under the hood, it's just javascript, with the same data types and object model. Coffeescript was created to provide a more succinct, expressive and powerful syntax while fixing its bad parts.

Having been implementd as a trans-compiler (or transpiler, which is a source to source compiler) I believe Coffeescript is the safer bet in the long term.

Creating a transpiler is easier than creating a whole language interpreter or vm from scratch, because you are leveraging an existing target. So, if Dart turns out to be a good target, chances are that someone will come up with a Coffee-to-Dart transpiler soon (or something that comes close).

You should decide which syntax you find more of your liking: C-like syntax (such as Java's or javascript's) or Pythonic-Rubyist syntax (more modern, expressive and, IMHO, more beautiful).

link|improve this answer
Who, exactly, suggested that Coffeescript is a "whole new language"? I don't see that (or any such suggestion) in any of the text. I might be missing it, though. – Brian Genisio Oct 10 '11 at 22:41
Fair enough, the comment above says "completely new language", not "whole new language" :-) – user876508 Oct 10 '11 at 23:00
1  
but... that quote was about Dart, not CS... – Brian Genisio Oct 11 '11 at 0:07
feedback

Do you already know Javascript? If not, learn it first, then learning coffeescript will be a small step.

Dart has just been announced, at the moment it's just a curiosity. Take another look at it in a year :)

link|improve this answer
feedback

When this company says that it will replace JS in the future, i think that's going to happen

This company - Google - develops, then drops, new technologies, all the time. How many people are using Google's "GO" language? Then there is Buzz, Wave, and many other projects that have been dropped by Google.

link|improve this answer
feedback

When this company says that it will replace JS in the future, i think that's going to happen, it's the first time that a new language is not only introduced but thought of being able to achieve such a target. In addition, the company is powerful enough to be able to change the way the web moves, so yes that's what it's probably going to be.

link|improve this answer
7  
If Microsoft couldn't make vbscript work when they had 90% browser share, there's no way that Dart will replace Javascript. Enhance/target/work side-b-side, sure. But not replace. – Sean McMillan Oct 12 '11 at 18:41
2  
@Sean: I'm not saying that Google will have easy time convincing web developers to transition to Dart (they most definitely won't), but that's still comparing apples to oranges. While Dart definitely improves on Javascript on most respects, VBScript wasn't an overall improve in Javascript. It did have some strengths over it (mostly better COM/ActiveX support and For Each), it was actually a major downgrade on most counts, especially with not support any kind of OOP or sane error handling. It had the expressive power of C, the beloved syntax of VB, and the speed of JScript. The perfect blend. – Boaz Yaniv Oct 15 '11 at 19:00
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.