The Dart Hello World

Via @qrush, a nice analysis of the compiled JavaScript code from a small Dart Hello World gist. Basically, this Dart code:

// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// VMOptions=--compile_all

class HelloDartTest {
  static testMain() {
    print("Hello, Darter!");

main() {

Compiles to 17259 lines of JavaScript code. Now, most of it is just the library core, but it shows what you have to do to bolt static typing on top of a prototype-based, dynamic, truly object-oriented language.

I don’t really understand the point of Dart personally, it seems like all that’s left is some 100K line XML file to drive behavior, and now we’ve built Java executing in the browser.

Be sure you check out the comments on that gist, it’s a gold mine of ready-made memes. My favorite so far:


About Jimmy Bogard

I'm a technical architect with Headspring in Austin, TX. I focus on DDD, distributed systems, and any other acronym-centric design/architecture/methodology. I created AutoMapper and am a co-author of the ASP.NET MVC in Action books.
This entry was posted in JavaScript. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Jakub Liska

    Dart code compiles to Dart code ? Eh..

    • Anonymous

      Ha, fixed. Compiles to JavaScript code.

  • Marcus Swope

    I don’t feel like this is a fair comparison, the ruby “Hello, World!” is only one line, however if you included the entire ruby framework in that calculation it would obviously be many more lines than that. The is the same for C#, we don’t count the number of lines of IL it takes to create a “Hello, World!” app or the number of lines in the BCL that are executed.

    Also, if DART were to ever become the language of choice for web development, the framework would almost definitely be build into the browser (at least Chrome) so that much information wouldn’t have to be sent over the wire anyway…

    All that being said, I still really don’t understand the point of DART.

    • Anonymous

      It’s not a comparison, really, it’s looking at what it takes to have Dart run in JS. The actual JS code is the interesting part, to me.

      Check the analysis in the link, it’s a fascinating read on JS code.

  • I seem to recall reading that the reason they created Dart is that there are too many JavaScript frameworks. This comes to mind (

    • David Evans

      The primary reasons for Google developing Dart is for the following reasons, Serialization of data, additional security running in a VM environment and running code nativity on the client environment(Think net-books, server applications and Cloud storage). The Dart to Java-Script conversion tool functionality is just to get developers to initially invest in learning Dart language knowing that their programs will run in any browser that currently supports Java Script and could/would start up quicker and run faster in the web browser supporting a Dart VM. This will be included in future version of the Chrome Browser, IMO probably also in the Fire-Fox Browser either via a community development effort or led directly by Google, for the IE web-browser probably when “HELL FREEZES OVER” and for Opera? Who knows.

  • This is BS. The point of dart is to create a language that can be more quickly compiled/interpreted by the browser – it is intended to be native. So its unfair and misleading to say “Dart compiles to Javascript”. The fact that Google has released (an early version of) a Dart-to-JS cross-compiler does not detract at all from that point.

    • Anonymous

      I just enjoyed the memes in the gist comments.

      I didn’t intend to imply that all Dart code compiles to JS, but that the compiled Dart code is really interesting in what you need to do to run a static-ish language on top of JS. Interesting, and silly.

  • I understand the point of Dart. When you’re writing 100s of Ks of lines of JavaScript code for your rich HTML5 application, it pretty quickly becomes hard to maintain, check and test. This is because JavaScript was hacked together to perform extremely simple tasks like form validation and basic DOM manipulation. Dart has been designed from the ground up as a language for creating complex applications. It doesn’t have to maintain backward compatibility with the hacky, lightweight language, so all the hacky, lightweight annoyances are not an issue.

    Also, because it’s been designed by a small team working together every day, it’s being developed very fast, unlike JavaScript, which is taking the “evolution” concept very literally in terms of the timescales involved.

    My issue is that I thought Google were working on a compiler that would take the proposed ES6 syntax and compile it to current JavaScript, which seems like a better use of development time. But I also like Dart’s concepts around types and interfaces and the compile/debug-time checking that enables.

  • “and now we’ve
    built Java executing in the browser.”

    Isn’t it exactly what google want to do with Dart? I mean they want a statically typed language so you can reason about code. This bring automatic refactotring, easy code navigation (call tree), more advenced metrics etc.

    We can like java or not, but it is effective for the kind of things Dart was invented: big projects with lot of developpers.

    If you think about yourself has a lone developper or work in small projects teams, Dart might not be the most productive tool.

    Differents needs, differents tool.

    And how? Did you check how big a modern JS VM is? To just print hello world in JS, you have to run a browser, an URL, a JS VM etc… And most machine would fail to do it with less than a few MB of memory… To display “Hello world”. Think about it.

  • Adam

    Check this out as well. C# like language that compiles to javascript.

  • Pingback: Why is javascript the only client side scripting language implemented in browsers? [closed] | PHP Developer Resource()

  • Ryan Martin

    Have you changed your opinion of Dart over the last year? I’ve been using it since M2 and find it to be fantastic and it’s still pre V1.