Google starts to detail Dart |
Written by Ian Elliot |
Monday, 10 October 2011 |
Google has released an early preview of Dart. It is as revolutionary as we might have hoped for a JavaScript killer - or is it just another Java clone?
A while back, Google allowed it to be known that it was proposing a second new language in addition to Go. The Dart language was later revealed to be a JavaScript replacement. It seemed that Google had decided the JavaScript just wasn't up to the job of building the web apps of the future and had decided to work towards its replacement rather than improvement. Hence Dart: a language for structured web programming. Now we have an early preview of Dart and there are no huge shocks - it's a class-based, object-oriented language. The design goals are stated as:
The only controversial aim is "familiar and natural" because it all depends on what you consider to be familiar and natural. JavaScript isn't class-based and this tends to annoy and confuse programmers brought up in the class-based language tradition of C++, Java and C#, say. It doesn't however mean that a non-class based approach is necessarily wrong for the web or for a dynamic language. Class-based languages generally impose strong typing, but such is the need to balance ease of use and dynamic aspects of the language that Dart is optionally typed. That is, you can start off with no typing and add it later. This, of course, makes little sense; the problem of sorting out type after the event is much more than enforcing it from the start. It leads to much more work than simply ignoring type and going typeless. A class-based language has a natural type hierarchy; a non-class-based language has about as much use for type as a fish has for a bicycle. It is also interesting to note what is missing. Functions are just functions and not objects and the language is single threaded. There are no namespace or modules and nothing much to aid large scale program development other than optional typing. From the implementation point of view, Dart has an interpreted VM mode and a compiled mode. In this case the twist is that the compiler targets JavaScript as the final code so Dart is just another language using JavaScript as its machine code. This does however have the advantage of making it run on any existing browser, but it hardly makes it a JavaScript killer - it simply elevates it to the role of the "native" language for browsers. The VM mode of implementation seems to be reserved for server side execution and this at least reveals that the intention is to have a single language for both client and server. As far as Dart goes, there seems to be nothing new. It is just the same old class-based, object-oriented language with optional typing to make it easier for beginners. You might as well just port Java, C++ or C# to do the job as invent a new language. Here is a hello world in Dart: main() { And here is a simple, typed, class definition and use: class Point { num x, y; Point(num this.x, num this.y); Point scale(num factor) => Notice the use of => as a shortcut to defining a function. More InformationDart: a language for structured web programming Goto conference
If you would like to be informed about new articles on I Programmer you can either follow us on Twitter or Facebook or you can subscribe to our weekly newsletter.
|
Last Updated ( Monday, 10 October 2011 ) |