« Stuff The Internet Says On Scalability For March 22, 2013 | Main | Sponsored Post: Fitbit, OLO, Amazon, aiCache, Aerospike, Percona, ScaleOut, New Relic, Logic Monitor, AppDynamics, ManageEngine, Site24x7 »
Wednesday
Mar202013

Dart - Is it the Future of the Web?

John McCutchan, after a long career spent working on the Linux kernel and being hired out as a code optimization guru, joined Google's Dart team. A curious hire until you watch Bringing SIMD to the Web via Dart, where John makes a programmer accessible explanation of why he likes Dart: performance, performance, performance.

Dart is an open-source Web programming language developed by Google. The motivation for Dart is twofold: provide a language capable of scaling up to the complex web applications that are becoming the norm. Think Gmail. And provide a single language capable of working on both the client and server. Towards those ends Dart is a complete language, full tool environment, and provides an advanced Web UI framework for building web applications at a high level of abstraction.

Why isn't JavaScript good enough? The fear is for large web apps the nature of JavaScript puts crippling limits on potential performance improvements, which will cause web apps to lose out to mobile apps. Before you scream in protest, Dart is created by the same guys who worked on V8, so all their JavaScript experience has fed into Dart.

John’s pitch is that despite many assertions to the contrary, the web is not fast. For example, when comparing the performance of a 2D physics engine across C and the web, the web version is 20x slower than C. Java is twice as slow as C. So the browser is not fast. Dart and the new libraries it supports can close that gap, allowing for the development of high performance applications in the browser.

You may be wondering which of the gazillion web frameworks to use and Dart may just be on the edge of your radar. If so this is an excellent video to take a look at.

Why might you like Dart? Here’s John’s list:

  • Loves structure and static type checking. Dart has a type system. Strangely though the type system is enforced by tools, it’s not a property of the language.

  • Class base and object oriented. JavaScript is too flexible.

  • Lexical this. Unlike JavaScript when you use this you know what it is referring to.

  • Semicolons are required.

  • Performance. Dart is designed to run fast by being less permissive than JavaScript. 

  • Newly written from scratch VM that is designed specifically for Dart and is designed to be fast.

  • In Dart every object has a static shape. In JavaScript fields can be added at any time, which invalidates any optimizations around instances of the class. Not possible in Dart. Remember, it’s less permissive than JavaScript.

  • Hole free arrays. In JavaScript elements can be added anywhere into an array at which point it will be converted to a map where an index is the key. It becomes sparse and is spread out through memory, which is horrible for performance. Dart does not let you do this.

  • Distinction between growable and fixed sized arrays. If you know the size of an array ahead of time then you can make it fixed sized array, which gives Dart more optimization opportunities.

  • No prototype chain in Dart. Big win. In JavaScript you find which method to execute by following a prototype chain. In Dart you extract the class ID go to the class a grab the function. It’s very fast.

  • Dart has both integers and doubles. Integer arithmetic is 3x-4x faster than double arithmetic. JavaScript pays an unnecessary price for making all numbers doubles.

The rest of the talk is quite interesting and is about him porting SIMD to Dart. SIMD means single instruction multiple data, which means an operation is applied in parallel to an array of data rather than to one piece of data at a time. This makes areas like 3G graphics, 3D physics, image processing, signal processing, and numerical processing, blisteringly fast. Which means you can get console level performance in the browser.

As the point of this post is a quick hit on Dart, you can see the rest of the SIMD talk on the video.

Is Dart the Future?

For Dart to win it must provide speed improvements so compelling that other applications are put at a clear competitive disadvantage, and not just in graphics intensive applications. Then either JavaScript interpreters will need to compete or developers may be forced to move. But this is not an area where Google can get customer wins just by being Google or by being marginally better. Quirky little JavaScript is much loved. JavaScript's ecosystem is both loved and extremely strong. The same ecosystem plays that Google makes in other areas may work against Google here.

Related Articles

Reader Comments (14)

The big question is "until", I think if Dart could close that performance gap then it will have a winner on its hand. There are many avenues that can not be explored due to performance limitations.

March 21, 2013 | Unregistered CommenterZen Master

While the performance is important the success of this platform will highly depend on if Google could quickly build infrastructure strong enough to make it practical. At given moment they do it right: IDE, libraries, etc. The other part will depend on people. Also dart will be interesting alternative to node platform.

March 21, 2013 | Unregistered CommenterAliaksandr Zhuhrou

@Zen Master
VM, and js cross compiler already faster on this benchmark:
http://www.dartlang.org/performance/

March 21, 2013 | Unregistered CommenterGreg Lowe

Your list of Dart points seems similar to C++ with the Emscripten compiler to Javascript.

It would be interesting to see the PROs and CONs between Dart and Emscripten with C++.
It will help if the PROs for dart versus emscripten are strong enough to motivate developers to learn a new language.

How cross-platform is Dart, beyond the browser?

March 21, 2013 | Unregistered CommenterErwin Coumans

I think Dart more as a contender for Java NOT javascript.... i see Dart replacing (not totally but for newer projects) Java in the business web apps side than in the regular web developing... i think that Google is tailoring Dart that way.

March 21, 2013 | Unregistered Commentersaome

Is dart created by the same guys who built Google Plus? Because Google Plus is unusable on my 2ghz Dual Core system. Scrolling doesn't even work really.

Hail to our new webscript overlords I guess.

March 22, 2013 | Unregistered CommenterLeonardo

@Erwin Coumans: The Dart VM can run on Windows, MacOS and Linux. At the same time you can create backend code the same way you do with node.js

@saome: Of course, due to its nature Dart will take a bite out of Java's market share when it comes to business web apps too. In real life there are bunch of projects in which Java looks like overkill while Javascript isn't scaling enough.

March 22, 2013 | Unregistered CommenterLucian Pacurar

Since Apple, Microsoft and Mozilla have all made it clear they have no intention of ever supporting Dart in their browsers, the answer to your question would appear to be a resounding "No." It's likely to see as much usage on the web as VBScript did.

Dart is too conservative and too constrained to appeal to anyone except die-hard Java fans who can't live without static typing and traditional classes and inheritance. JavaScript developers aren't likely to be swayed by a language's whose main selling point is reduced flexibility and permissiveness. They LIKE the flexibility and permissiveness of JavaScript. Particularly since the theoretical performance benefits aren't delivered in practice due to the requirement to compile to JavaScript for the majority of browsers (see my first point).

ASM.js provides a much better approach to writing high performance code in JavaScript, one that is backwards compatible without requiring pre-compilation. And the new features of ECMAScript Harmony should improve the language's semantics and support for large-scale programming, without requiring us to turn the clock back to 1995 and all become Java programmers.For all the hyperbole about fixing the web, Dart's main purpose appears to have been to placate and retain Lars Bak, so he'll keep working on V8. It's just a shame that such a brilliant virtual-machine engineer turned out such a boring and conservative language.

Case in point: Asynchronous programming. Almost all I/O operations on the web, such as AJAX requests, should be done asynchronously. In JavaScript, this is usually done via callback functions, which is generalised into the promise/future pattern. However, modern languages, such as C# and ECMAScript Harmony build this directly into the language via async and await keywords that allow code to transparently yield and await the result of some long-running I/O task. Dart has nothing along these lines, instead just providing regular promises.

In so many areas, Dart missed the opportunity to really innovate and explore what a modern language for the web should be. Instead, they preferred to paper over a few of JavaScript's more confusing aspects in order to make Java developers feel more at home. If that's that's the future of web development, I'll stick with the past.

March 23, 2013 | Unregistered CommenterJon

According to Betteridge's law of headlines. No.

March 24, 2013 | Unregistered CommenterLOL

I'd say the major advantage of Dart is that it will run Newspeak.

March 25, 2013 | Unregistered CommenterStephan Eggermont

I'd really like to see Dart succeed because it has so much potential. And I absolutely don't understand javascript people who are afraid of everything new. If it's better for both developer and the end user why the big opposition? Are you guys afraid you'll have to learn a proper language other than tweaking script snippets all over?
I have written many js applications and it simply doesn't scale well...and yes there can be performance issues too.
The seeming "flexibility" of javascript will hit you right back in your face when writing anything serious.

March 27, 2013 | Unregistered CommenterAnd111

In general this will be good for serious guys but I doubt it will attract crowds because it requires a lot of discipline. Finally one can distinguish good apps from bad.

March 31, 2013 | Unregistered Commentermanoj

I'm programming in javascript intensively for at least 6 years now. And as a javascript developer I really see the benefits of Dart. For me those javascript developers who says that Dart is not worth or something along the line are just scripters who puts jquery to move something on the page. Yes, there are serious javascript developers out there and surely YES they will embrace Dart.

September 8, 2013 | Unregistered Commenterauthor

Well they have made it 20x faster today

http://news.dartlang.org/2013/10/faster-dart2js-and-new-html-editor-in.html?m=1

October 2, 2013 | Unregistered CommenterSayth

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>