Google Helps Devs Convert JavaScript To Dart
Google Helps Devs Convert JavaScript To Dart
Written by Ian Elliot   
Tuesday, 31 January 2012

Google has realized that as most programmers know JavaScript, one good way to get them to use Dart is to provide a guide for the JavaScript programmer.

How do you get programmers to switch language?

The most obvious way is to make sure that the new language is so good that you would be an idiot not to use it. Failing this simple strategy, you can also attempt to lower the barrier to moving to the new language.

Dart is Google's proposed replacement for JavaScript and in its basic form it takes a program written in Dart and converts it to JavaScript so that it can run in any browser. Now Google has realized that, as most programmers know JavaScript, one good way to get them to use Dart is to provide a guide for the JavaScript programmer.

JavaScript to Dart Synonym is a website that lists common JavaScript idioms and how these translate to Dart.





To quote Aaron Wheeler on the Google Code blog:

We started with the basics that every JavaScript and jQuery developer knows: variables, arrays, functions, classes, DOM manipulation, and many more. Then, with the help of the Dart team, we recorded the corresponding Dart versions of each idiom. To practice what we learned, we wrote this app with Dart.

The problem with a lexicon of this sort is that it varies from the trivial and the obvious though to the very subtle. For example, the fairly obvious:


var numbers = [42, 2.1, 5, 0.1, 391];
numbers.sort(function(a, b) {
  return a - b;


var numbers = [42, 2.1, 5, 0.1, 391];
numbers.sort((a, b) => a - b);

the very subtle:


function Person() { = null;

Person.prototype.greet = function() {
  return 'Hello, ' +;


class Person {
  var name;
  greet() => 'Hello, $name';

If you know any JavaScript, you will know that this covers up a huge range of options in how you create a class. This is no syntactic change.




And to an extent this is the problem. If new language just involves a syntactic change then it is almost sure to be a worthless swap. To get any real advantage there have to be some semantic changes which cannot be expressed simply as an "instead of writing this" type rule. To make use of a new language you have to think different or the language isn't worth the effort.

So thanks to Google for the effort, but it is going to take something more than this to get Dart to the number one slot.

More Information 

Translating JavaScript to Dart

Related Articles

Google starts to detail Dart

Google spawns yet another language - Dart


blog comments powered by Disqus


To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook or sign up for our weekly newsletter.


Android Studio 2 In Preview

Soon after the release of Android Studio 1.6 to the stable channel, Google is showing off what a full version 2.0 will look like. 

Visual Studio Code - Now With Added Extensions

Visual Studio Code is a strange product from Microsoft. It is a code editor, but Visual Studio it isn't. Now it's open source and you can build extensions for it. 

More News

Last Updated ( Tuesday, 31 January 2012 )

RSS feed of news items only
I Programmer News
Copyright © 2015 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.