Introduction to Google Dart – new Javascript alternative language

Dart Logo

Google announced its new programming language “Dart” at GoTo Conference in October 2011. Google highlights it as a language for “Structured Language for Web Programming”. Dart is a class based, optionally typed programming language. The language as such is not a replacement for Javascript, but offers a modern alternative for scripting in web browsers.

Why one more new language?

There are umpteen number of programming languages out in the wild each of which say problems faced by other languages have been addressed. Dart is a new addition to the stack which is intended to solve Javascript’s problems which can’t be solved just by evolving the language. Dart mainly concentrates on better performance and scale-ability.  We all know that developing feature rich heavy applications with Javascript is not so easy even though we have a couple of nice framework’s such as jQuery, Backbone.js, Knockout.js, Ext.js etc. and Dart addresses such limitations.

Dart’s design goals included: to be a structured yet flexible language, to be familiar and natural for programmers, and to meet high performance. We have many options for server-side language, but when it comes to browser we are limited to Javascript. Falsh was used earlier to do the same but now it is fading away due to many factors.

How will Dart help overcome problems of Javascript?

Dart has supports optional types; so you can  start coding without types initially and add types as and when needed.  If you declare types, Dart generates possible warnings – not errors. With existing languages, developer has to choose between static or dynamic languages which need heavyweight tool-chains and a coding style. Javascript doesn’t care whether you assign an integer or a string to a variable as it is weakly typed. Many a times this causes some hard to catch errors. Dart addresses this by providing enabling just enough type safety.

Dart is a structured language and allows to organize code in a modular style splitting it up in to different functions. This enables developer to write maintainable code and is easy to change that searching across a bunch of “if else” conditions in a single block of code. Dart is developed considering huge applications and large teams to build highly complex and scale-able applications. For example in javascript, code from all the

One big bummer with javascript is it tries to execute whatever code it can and as soon it can before even the DOM loads completely leading to undesirable effects. With jQuery developers always make sure that the functions calls go in to document.ready() function. Dart solves this problem by waiting till the DOM completely loads.

Compatibility

With enough of issues and unsupported features of javascript which is there in the field since they bygone age, we are moving on to a new language. Browser compatibility is always a concern as some times developers have to code for specific browsers. Dart can easily be compiled to javascript on the fly so it supports all the browsers that are around. Google Chrome comes with a native Virtual Machine which runs dart on the fly. Competing browsers can also implement the VM over a time. That depends on the popularity and utility of the language; now the language is very new and there is a long time for it to gain popularity.

Google is developing a cloud based IDE for Dart which possibly be the first Dart application would attract the crowd to jump in to the language.

Is it time for me to learn Dart?

Dart is in its early stage and it is quite difficult to say whether it is the next big thing that will happen on the client side programming. The language is pretty neat and very easy and provides many improvements over the limitations of Javascript. Right now the documentation provided by Google is very limited. There are not many tutorials available online  no books are available on Dart. If you want to explore the features, then the basic examples provided on Dart’s Home page would be enough. If you wish to use it in your next project, may be it is not the right time to start using it.

[Update]

Dart is already getting some traction..! Someone made a Dart to JVM bytecode converter called jdart which takes a Dart file as input and creates a .jar file. It is limited in features but who knows what comes up next..! So gear up now and start with Dart.

Be Sociable, Share!

Related posts:

You can leave a response, or trackback from your own site.

Leave a Reply

More in Programming (3 of 5 articles)