A year on from its initial release, Google Dart’s Milestone 1 has a whole raft of improvements and new features, though the removal of the string concatenation for performance and consistency reasons has left a few scratching their heads. It’s OK, though. You can also use StringBuffer, string interpolation (see below) to concatenate string literals.
What isn’t in doubt is that Dart is starting to gain traction, having recently entered the Tiobe Index Top 50 and is currently at the 43rd spot — just above ActionScript!
int a= 7;
a =’Fred’; // Error !
You aren’t tied to declaring everything in classes in Dart, though. Functions, variables and even getters and setters can be declared at the top level.
Earlier, I mentioned string interpolation to overcome the removal of + for string concatenation. Use the $ prefix to expand variables inside strings (not unlike PHP).
var name = ‘David’;
var title = ‘My Name is’;
var greeting = ‘$title: $name’;
No prizes for guessing that greeting now holds ‘My Name is: David’. Who needs +?
I have to say that one of the things that lets Dart down is the spec. The Dart team should take a leaf out of the Golang (Google Go) website and the spec of Go there. It’s better laid out, easier and much less tedious to read.
I’ll be increasing Dart coverage of Dart here soon with lessons on how to get started and use it.