Dart programming language design
johndcook.com
johndcook.com
Of course, Java was designed in such a way and became widespread if not beloved. But then it too won what Bracha (in pooh-poohing Javascript's success) calls a "language lottery", meaning it benefitted from an accident of timing. Barring that happening for Dart, it seems unlikely that lots of smart programmers will get very excited about it.
One interesting point in Bracha's talk: he mentions the Dart VM more as a server-side platform - basically an alternative to Node.js - than as something they would ship to the client in Chrome. The client-side story, at least for now, is that Dart always compiles to JS. And he claims that they've already got compiled Dart to be about as fast as handwritten JS, which is surprising.
Why bother with optional types (if you're enlightened enough to realise that you can just throw them away, since they're not needed for optimisation) when you could have richer compile-time contracts? Why bother with classes at all, when you could just have prototypal inheritance + interfaces?
I don't quite get what the goal is.
As for its boring syntax, this won't be a problem. Coffeescript demonstrated that you can target a messy language and make it beatiful and fun. Dart already has a "transpiler" for compiling it down to javascript. If Dart becomes a good compilation target (and it looks so), people will start wrting their own transpilers targeting Dart. The best of both worlds. As for the concerns about the null chance of other browsers adopting Dart, this is a battle they can't win. Dart will run everywhere, either on its own VM or compiled to javascript. And it will lead to a situation where new applications run on every browser, but "work best on Chrome". How long will the other vendors keep on pushing a mediocre, substandard language such as javascript when Dart is already making developers lives easier, and applications faster and better?
This is a blasphemy towards static typing. Whenever the size of a software system stops being trivial, static typing is a must have to assume any kind of robustness. I cannot think of refactoring thousands of lines of code written in a dynamically typed language and sleep peacefully in the night. On the other hand, I can rely on the linker/compiler errors to, at the very least, flag any type misuse introduced due to my changes, in a statically typed one.
> We’re not out to take JavaScript away. We’re not that stupid. I personally if I could I would, but Google probably wouldn’t.
I know it's cool to hate on JavaScript these days. But it just doesn't deserve it quite that much. And, wrong as that analogy may be, it smells like someone coding mostly in C++ talking about why C sucks.
This has dynamic closure. Everything else has lexical closure.
Vars can be declared inside a block but it has no effect, because they are always scoped to the nearest function.
Variables must be declared with var, or they will still work but they will be scoped to the global environment.
Equality isn't transitive.
NaN is not NaN.
The way to convert a number to a string? Append a string.
aString + aNumber = aString
aString - aNumber = NaN
etc.
You can always call intVar.toString() if it pleases.