Making Dart work will require a new virtual machine, which puts it on a competitive plane with Java, Adobe Flash, and Microsoft Silverlight. But architecturally speaking, Dart will be more dependent on the browser, at least for now.
At last, class
class keyword familiar to Java developers, is the key addition.
function. You can declare a function which happens to have properties, and whose function is embedded therein as a kind of method. The problem with that is that the method itself doesn't get re-used but rather recreated each time, so the alternative is to add the method back to the function's
prototype as a kind of bolt-on. Alternately, you can declare a kind of object using the all-purpose instantiator
var, which may use literals to define internal structures. You then assign a
function as a method for one of those literals as though it were a variable value. Or, you could declare a
var and assign the whole thing the result of a
function, assuming that function were to be the only component of the object.
So theoretically, the performance hit incurred by a browser running the Dart VM may be compensated for, by way of code that's easier for the JS interpreter to parse. Theoretically.
class in a way that will be familiar to most Java programmers. A few tweaks make the definitions more concise; for example, the reflexive pointer
this may be used inside the declarative for a member method (as in
Ball.throw (this.distance); instead of
Ball.throw (distance); this.distance = distance;). And
interface is also supported for creating member properties and methods that may be common to more than one class; a class
implements an interface just as you'd expect.
Still unknown: event triggers
main() function, most functions are triggered by browser events, including
window.onload. With Dart, every
<script> element is a self-contained context. Class members and variables are considered public by default (there's no "public" keyword in Dart), although "public" for Dart is not a scope that encompasses the entire page - just the script.
#import. Each script tag must define its own
main() entry point in order to run."
main() function is the event handler for the
But conceivably, this scheme could facilitate a fairly simple and straightforward approach to multithreading: A page could have multiple scripts, and the VM could run them in parallel... again, theoretically, according to the early documentation. Browsers don't have multithreading interpreters yet, and Dart is not described thus far as something that will include a JS interpreter, so it's difficult to see how Dart would invoke a feature that doesn't actually exist.
Nevertheless, from an architectural standpoint, there's a lot to like about Dart, and there's reason to believe its wealth of opportunity will be spread among multiple browsers, including even Internet Explorer. What remains to be seen is how Dart will impact browser-free HTML5 apps, or "native apps," if at all. We'll be monitoring the news from the developers' conferences as well as from Google itself this week.