On Tue, Oct 18, 2011 at 12:53 AM, 127 <mamyashev.ma
...@gmail.com> wrote:
> I like Dart very much, but ther's one thing that makes me confused.
> Is there any general obvious advantage over Coffeescript? Coffeescript
> has «normal» class based OOP and it's compiled JS is much more
> readable and clear (+small).
CoffeeScript and Dart are going in different directions (neither of which is
bad, they just suit different uses and users). CoffeeScript starts with JS
and says, "Let's see if we can improve the syntax." I, like a lot of people,
find CoffeeScript generally more beautiful to read than vanilla JS, but it's
underlying semantic model is still 100% JS:
1. Everything is mutable.
2. CoffeeScript does add a declarative form for classes, but that doesn't
include fields, and it doesn't ensure that the class isn't later modified.
3. No type annotations.
Simplifying drastically, you can look at Dart as starting with JS and saying
"Let's see if we can improve the semantics." So Dart still looks a lot like
JS (or a hybrid of JS and Java), but its underlying semantics are quite
different:
1. Actual classes, no prototypes. No object literals.
2. Distinction between objects-as-instances-of-types and
objects-as-data-structures (maps).
3. Classes have a purely declarative form and cannot be changed after the
fact.
4. Optional type system and type annotations.
If you find yourself liking JS but wanting it to be more terse and
expressive, CoffeeScript is a good fit for you. If you like JS but want it
to be more structured and easier to tool, then Dart is a better fit, I
think.
That isn't to say the two are mutually exclusive. Dart's => functions are
inspired in part by CoffeeScript, for example.
- bob