Over a million developers have joined DZone.

Why Dart Comes with a Virtual Machine

DZone's Guide to

Why Dart Comes with a Virtual Machine

· Performance Zone
Free Resource

Discover 50 of the latest mobile performance statistics with the Ultimate Guide to Digital Experience Monitoring, brought to you in partnership with Catchpoint.

Dart comes with a high-performance virtual machine. This controversial decision led to questions if it is going to break the Web. In this article I want to look at why we need this virtual machine, and how it can be added to Chrome without breaking the Web.

Server Side

One place where even the strongest opponents of Dart will not mind using the Dart VM is the server side. The Dart execution model is very similar to the one in Node.js. In addition, the Dart virtual machine is already much faster than V8, and also has a good concurrency story. All this makes it a good candidate for writing high-performance IO-intensive services.

During Development

When compiling a language with different semantics to JavaScript, there are a few options available:

  • The compiler is fast, but naive.
  • The compiler is advanced, but not as fast.

The Dart engineers picked the latter. The generated JavaScript code is fast and small, but the compilation process takes some time. Which is not a big deal when you compile your app before pushing it to production. It is an issue, however, when you are developing. Even if the compilation takes a second, it is a second too long. Having the Dart VM is crucial for providing the same interactive development experience we all love.


Embedding the VM into to browser gives you better performance and start-up time. I am not talking about marginal gains here. It is about twice as fast comparing to V8, and the start-up time for some apps can be speeded up by a factor of ten. Both are extremely important, especially on mobile devices.

The issue that rightfully concerns many programmers is how do we make sure Dart developers provide the compiled-to-js version of their programs. Only in this case their applications will work in all modern browsers.

How not to break the Web

One way to ship Chrome with the Dart VM, and make sure that Dart applications work in all modern browsers, is to request the JavaScript versions of the applications from time to time. So even if you use a browser with the Dart VM in it, you will get the JavaScript versions of Dart programs every tenth time. This will ensure that developers will provide the compiled-to-js versions of their programs. By the way, this strategy is not new. It was successfully used when the support of the SPDY protocol was added to Chrome.

Summing Up

Having a dedicated VM has a lot of benefits:

  1. The VM can be used on the server side.
  2. The VM can be used to speed up development process.
  3. The VM can be shipped to the browser to improve the startup time and the speed of applications, and it can be done without breaking the Web.

Is your APM strategy broken? This ebook explores the latest in Gartner research to help you learn how to close the end-user experience gap in APM, brought to you in partnership with Catchpoint.


Published at DZone with permission of Victor Savkin, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}