> not that far from Java
This is something that hurt us, I think. You can write Dart code that looks a lot like Java, and many of our early public examples did. To make matters worse, for no good reason, Dart 1.0 didn't do any type inference, so even though you could use "var" for local variables, doing so would give you a worse user experience.
But you don't have to write Java in Dart. You can write really elegant, clean code in Dart in a way that Java doesn't enable. You don't have to stuff everything inside classes. We've always had nice terse lambdas, higher-order functions, collection literals, etc.
Here's a random little program of mine:
import 'package:hauberk/src/engine.dart';
import 'package:hauberk/src/content.dart';
main() {
var content = createContent();
var save = content.createHero("blah");
while (true) {
var watch = Stopwatch();
watch.start();
// Generate a dungeon at each level.
var count = 0;
for (var i = 1; i <= Option.maxDepth; i++) {
var game = Game(content, save, 1);
for (var _ in game.generate());
// Read some bit of game data so the JIT doesn't optimize the whole
// program away as dead code.
if (game.hero.pos.x >= -1) count++;
}
watch.stop();
print("Generated $count dungeons in ${watch.elapsedMilliseconds}ms");
}
}
It's not the most beautiful code in the world, but I do think it's a good bit simpler and cleaner than it would be in Java.