Monday, October 10, 2011

Dart: a language for structured web programming

Author Photo
By Lars Bak, Software Engineer, Dart Team

Cross-posted on the Chromium Blog

Today we are introducing an early preview of Dart, a class-based optionally typed programming language for building web applications. Dart’s design goals are:
  • Create a structured yet flexible language for web programming.
  • Make Dart feel familiar and natural to programmers and thus easy to learn.
  • Ensure that Dart delivers high performance on all modern web browsers and environments ranging from small handheld devices to server-side execution.
Dart targets a wide range of development scenarios: from a one-person project without much structure to a large-scale project needing formal types in the code to state programmer intent. To support this wide range of projects, Dart has optional types; this means you can start coding without types and add them later as needed. We believe Dart will be great for writing large web applications.

Dart code can be executed in two different ways: either on a native virtual machine or on top of a JavaScript engine by using a compiler that translates Dart code to JavaScript. This means you can write a web application in Dart and have it compiled and run on any modern browser. The Dart VM is not currently integrated in Chrome but we plan to explore this option.

The language comes with a set of basic libraries and tools for checking, compiling, and running Dart code, all of which will evolve further with your participation. We've made the language and preliminary tools available as open source on dartlang.org. Check out the site to give feedback, learn more about Dart, and participate in its development.

We look forward to rapidly evolving Dart into a solid platform for structured web programming.


Lars Bak is a veteran virtual machinist, leaving marks on several software systems: Beta, Self, Strongtalk, Sun's HotSpot and CLDC HI, OOVM Smalltalk, and V8.

Posted by Scott Knaster, Editor

105 comments:

  1. Looking forward to it. Loved the OO concept and compiling it to pure JavaScript.

    ReplyDelete
  2. My wish: Integrate a cut-down CLR (e.g. parts of Mono) into the browser. Then we could choose which language we use to develop for the client side.

    ReplyDelete
  3. what are the prerequisites to learn this

    ReplyDelete
  4. Why is dart relevant when there already is javascript ? Is it like an option thing ? What does it provide that Javascript doesn't ? The class-based object oriented design when compared to javascript prototype based object oriented design ? Can someone please explain ... thanks

    ReplyDelete
    Replies
    1. It's easier for developer to write in it and have it converted to JavaScript. You can also use it for server code as well. This means that you can reuse code throughout you application. It also provides things that JavaScript doesn't like functions and being able to declare types.

      Delete
  5. Strange that we see again a new language from google. From my point of view mono is the best choice to run on browser site if it possible...

    ReplyDelete
  6. Hi Dart Team,

    is Dart in any way related to Google's Closure Tools? Are you using the Closure Compiler to produce your JavaScript?

    Thanks,

    Jan

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. looking forward to work with it

    ReplyDelete
  9. Competing standards

    http://xkcd.com/927/

    ReplyDelete
  10. Now if we could drop those ugly semi-colons :-)
    http://glaforge.appspot.com/article/google-announces-dart-new-language-for-the-web

    ReplyDelete
  11. is there a flag we can turn on to see the dart demo in chrome canary build?

    ReplyDelete
  12. I hope they'll get rid of the semi-colons at the end, a la Coffeescript. So annoying, if Ruby can do it, why not this?

    ReplyDelete
  13. @Rik: it is called "Silverlight", and we all know how it ended up :)

    ReplyDelete
  14. Nothing for Opera browser? :sad:

    ReplyDelete
  15. What about the DOM ? how is it gonna bypass javascript limits ?

    ReplyDelete
  16. Works nicely in Opera Next (aka Opera 12)

    ReplyDelete
  17. So if I can run Dart as a Javascript compiled code, why shouldn't I just write native Javascript? Or Coffeescript?

    ReplyDelete
  18. We already have a new JavaScript language, it's called ecma.next!

    ReplyDelete
  19. What would be great would be to create a language plugin feature that would make it easy to port existing languages to compile to V8 bytecode, like Clojure, Scala do on the JVM.

    ReplyDelete
  20. I was being sarcastic, but seriously, coffeescript is looking like a real contender, succinct and powerful. I'd like to see the same syntactic sugar that coffeescript brings while maintaining the dynamism that javascript has.

    ReplyDelete
  21. From what I have seen, I'm not sure Dart is bold enough!

    Just adding a class-construct (reserved word in EcmaScript) and typing the language feels like such a waste. Using Dart will not empower the developer to use newer Paradigms, and if a ci server with unit tests is in place shurely does not add much security. I really like the idea of a modern frontend language, but don't think a mere evolution will cut the deal.

    - Where are Feature-Oriented concepts?
    - I really am missing makro processing for internal DSL's
    - Shouldn't there be a event system build into the languages core?

    ReplyDelete
  22. @ot Silverlight is a plug-in which does its own thing. What I'm talking about is hosting a CLR and letting us work with CLR-targetting languages in the same way as we do with JS, i.e. operating on the DOM and source or being written within or referenced HTML - and the possibility of referencing IL, so you could use whatever language you liked and compile it to IL, freeing up the developer (and also saving a little time on the client, as there's only the IL->native step to perform).

    The JVM is a bad idea because, well, Oracle are being a pain about it, as expected.

    ReplyDelete
  23. nice to see the language open source right off the bat..
    to all those eho believe that it is not feature rich and lacks something that they believe the language should have, please help by contributing to the project and improve upon it. that is the point of open source after all.
    my best wishes to the dart team, lets see how dart evolves..

    ReplyDelete
  24. Sounds like HD Photo or WebP... too little too late.

    Instead of creating yet another language, Google should have just concentrated on getting existing JavaScript development experience better.

    If I wanted to go through yet another intermediate translation layer, I would have chosen CoffeeScript already.

    ReplyDelete
  25. How does it compare with Ocsigen?
    http://ocsigen.org

    ReplyDelete
  26. If Dart can be compiled into Javascript why wouldn't I just write the code in JS in the first place?

    ReplyDelete
  27. Hi Lars,

    As we're already terminating each line with an unescaped carriage return, what is the purpose of the semicolons?

    As we're already marking blocks by indentation, what is the purpose of the braces?

    Perhaps it might be better to remove these redundant elements like other, modern web languages, ie, coffeescript. This means programmers wouldnt have to chase missing semicolons, or worry about code that executes differently from it looks.

    Thanks,

    Mike

    ReplyDelete
  28. Just looking at the example it looks like a very poor project and bad idea.

    Why would I want a new language if I have to write like and ancient one.

    main
    print 'Why do I need more than this to work properly?'
    end

    ReplyDelete
  29. ClojureScript, ParenScript, CoffeeScript... and now Dart?

    It is indeed better to have a standard language runtime/VM in the web browser, and let the developers choose whichever language they like, rather than force them to learn quirks of yet another JavaScript-like language.

    ClojureScript is a better choice now. It works, it is the same (nice) language as Clojure, so it is easier to target web and desktop platforms at once with Clojure.

    ReplyDelete
    Replies
    1. +1 Standardize on a decent VM (any JavaScript one does not cut it) and let me program in my favorite language.

      Delete
  30. I'll be very interested to see how this pans out.

    ReplyDelete
  31. Interesting that so many developers dislike semicolons. When your page is 500+ lines those colones can help break up the page. Also it seems that for those of you new to JS that you are forgetting how easy it is to do JavaScript Code-Bloat.

    Your page becomes huge unyielding to even simple attempts to debug. No for sure a common language that can compile down to JS is very cool.

    I'm an application Architect for a fortune 5 company and can tell you all this is pretty cool stuff...

    ReplyDelete
  32. Shame its only going to work in a few browsers, making it pointless.

    ReplyDelete
  33. I would like to see an article explaing why use Dart instead of CoffeeScript, for instance. After all, CoffeeScript also supports class constructors. So, what else is supported by Dart that is not supported by CoffeeScript?

    ReplyDelete
  34. Smells like Java ... I have several questions:

    1. Looks like the type system is not going very far ... have you even considered using it to rid us of null pointers? Doesn't look like it.

    2. Are there any new functional programming-style constructs? Mozilla's latest Javascripts have had array comprehensions and generators. Instead here we get those abominable Java/C++ style iterators ...

    All in all this really has a 90s feel to it.

    ReplyDelete
  35. Great!
    Looks like ECMAScript 6 -- http://www.infoworld.com/d/application-development/javascript-upgrade-feature-modularization-174251 -- can take a hint or two in its design. Large systems cannot be manageably programmed without some sort of a class concept.

    ReplyDelete
  36. This page crashes Safari. Not a good first impression... :(

    ReplyDelete
  37. The JVM thingy aside, what does Dart do that GWT does not?

    I don't get it.

    ReplyDelete
  38. Google, Y U NO re-use purty Go language syntax?

    ReplyDelete
  39. I read comments about node.js, CoffeScript, Ocsigen…
    And what about OPA?

    OPA is a strong typed language that produce a checked and optimized JS.
    But it also takes care of all the server side and client/server communication!

    Check http://opalang.org

    ReplyDelete
  40. This is not enough paradigm shift for me over existing JavaScript (in fact, it feels like a step backwards). CoffeeScript, however, is pushing the envelope.

    What we really need is a language that pulls in the DOM-ease of jQuery, the data-binding ease of KnockoutJS, and the syntactical sugar of CoffeeScript.

    ReplyDelete
  41. Element element = document.getElementById('message')

    This makes me wince. 2001 just called! Firstly, no DOM-query capability like Jquery. Secondly, no Type inference! Go, C++0x and D all have it today!

    ReplyDelete
  42. It looks like Dart found a perfect balance between Java and JavaScript, simplyfing JS yet making it easier and more maintainable to build larger web apps, with IDE tooling.

    Pretty exciting news, reminds me of Java launch (which looked so close to C++ to many initially)!

    ReplyDelete
  43. Why does everything have to look like fu**ing java? Why those semicolons? Why braces?? We need a world without braces!!!

    Anyway, if Dart turns out to be a good language (and an efficient vm, which I'm sure it's guaranteed by Bak and Co), there will be other new Coffeescript-like transpilers targeting it.

    ReplyDelete
  44. Oh look, Ma.
    It's Actionscript 2.0 for Javascript, 8 years later...

    ReplyDelete
  45. Is dis d future language 4 Android???

    ReplyDelete
  46. Aikido was released by Sun in 2003 - and everyone promptly ignored it. Classes, optional semicolons, closures, interfaces, etc. Maybe this will have better luck.

    ReplyDelete
  47. Very good, when this language will published?

    ReplyDelete
  48. Really? The 80's just called and they want their curly braces and semi-colons back.

    ReplyDelete
  49. could you make dart compiled binary and make it harder to extract source code from the browser than it is from js?
    js encryption or obfuscation fails to protect code and making games or other valuable applications on the web with html5+js..feels like opensource. good luck

    ReplyDelete
  50. When Sun created Java, they decided to make it look like C and C++.
    When Netscape created Javascript, they decided to make it look like Java.
    When Microsof created C#, they decided to make it look like Java too.
    PHP was created so it looked like, again, all of the above...
    Enter Google, and created Go! Which looks like... yeah, you know.
    But now, finally, Google decided to break new ground and created Dart!!!!

    Do you know how it looks...?

    ReplyDelete
  51. Yeah!!! If Dart has great performance I'll use it for future my projects. Really smells like Java, thats cool thing ^.^

    ReplyDelete
  52. Anyone who has worked on a medium to large scale web app, with thousands of lines of JavaScript code, will understand just how great the new Dart language is. It feels to me like those who argue that they'd rather write pure JavaScript code, since that's what Dart compiles down to currently, would be able to better understand how great Dart is if they were to work on a large scale JavaScript project for a long period of time. Trust me, Dart is here to stay.

    ReplyDelete
  53. Going to start teaching myself! Thank you Google

    ReplyDelete
  54. uh cant say im exactly impressed with this, have always had a hatred for js. First it gets put into html5, and now dart. i would rather an overhaul of php, or rewrite c++ for the web, no not java(aka resource hog). On another note leave the semicolons alone, they work well and define the end far better then whitespace.

    ReplyDelete
  55. forkin' the community is how we roll, now.

    ReplyDelete
  56. This comment has been removed by the author.

    ReplyDelete
  57. I'm digging it. I think you have a winner!

    ReplyDelete
  58. There's unsound data types. Those new languages are too "modern" and messed. Operator overloading? Cmon!

    We need a typed and tool friendly JavaScript (or you can copy Java and change it's name).

    Anything out of this line will not have my attention for more than some few moments and I hope not yours too.

    ReplyDelete
  59. The idea to replace JS is great.
    DartSyntax and the thread-concept looks for me good.
    An other idea is:
    Why don't you take Groovy or only the Groovy-Syntax.
    If you plan to integrate Dart in Browser, may be you must provide also a fastLoadingVM or alternativly a fast interpreter.

    ReplyDelete
  60. Hope you bring an Eclipse plugin with great DART support and type-ahead (intellisense). Won't make headstands to try the current version and install VS and depot_tools on Windows.
    Good luck, this language looks promising... a little bit like loving Java :D

    ReplyDelete
  61. Great i respect your thoughts . I think it can work on any platform . Thanks for sharing it

    ReplyDelete
  62. Could you provide a service like this, that would make it easier to start out using dart.

    <script type="text/javascript" src="dart2js.dartlang.org?dartsrc=www.example.com/dartscript.dart"></script>

    ReplyDelete
  63. This comment has been removed by the author.

    ReplyDelete
  64. Intention is good but I seriously doubt to replace JavaScript just because of its monopoly, it has very deep root.

    Thanks
    Javin
    10 example of grep command in unix

    ReplyDelete
  65. the language itself (syntax, ugly semicolon, etc.) is not that appealing ... but i'd loved to see an example of how the language construct itself may help to speed up web app launch time and execution speed.

    ReplyDelete
  66. So, are you guys going to invent a new language a year?

    ReplyDelete
  67. My take
    http://enterprise-strategy-architecture.blogspot.com/2011/10/dart-overview-of-googles-new-web.html

    ReplyDelete
  68. All those complainers about "Why wouldn't I just write JavaScript in the first place" must be ignorant to the commonly perceived deficiencies of JavaScript. The language itself is complex and convoluted, whereas things like CoffeeScript and *supposedly* Dart fill the need for developers to perform more object-based development. Also, until browsers start accepting alternatives to JavaScript natively, what other option is there to compile code into JavaScript??? The fact that they are going to provide a VM is at least taking things a step further to solve a blaring issue.

    Hater's gonna hate. Go Google!

    ReplyDelete
  69. One of Google's hallmarks is not invent something that has already been invented. Mostly, by focusing scarce resources on unexplored or under-explored areas of computing. Based on what is outlined, DART does not appear to live up to this standard. However, I will reserve judgement until I get to play with it.

    ReplyDelete
  70. looking forward to code something big!

    ReplyDelete
  71. I don't think the world needs another language. It would be better if Google first finished what it has started -- assign some adult supervision to the Google Docs scripting language and elevate it from the childrens' hobby shop that it now is. For example, ensure that anything that the spreadsheet user can do through the UI can also be done via a script. Right now, a script cannot even copy and paste a row.

    ReplyDelete
  72. Why waste time to make it runnable "on top of a JavaScript engine"? Javascript is clearly a gone platform so Dart should have clean separation from it to unleash its full potential.

    ReplyDelete
  73. @EricBerry

    Like all languages, JavaScript may have a few warts but people (Java devs in particular) have a bad habit of confusing language design tradeoffs for doing things "the wrong way."

    I really can't help but get the sense that Google culture doesn't allow JS expertise to amount to anything other than a 'nice plus' on an engineer's resume, which might explain why Closure's JS library was so incredibly lame (not to mention Java-centric) or why they still haven't figured out how to get tens of thousands of lines in Google Apps spreadsheets without crashing the browser.

    If JS is such a clumsy, messy, awful language, why do JS devs tend to eschew IDE bloat in favor of just coding in consoles and color-coded text editors. And do you really believe that every single serious JS-focused but otherwise multilingual dev out there wouldn't immediately reach for Eclipse classic the second we had to write so much as a "Hello World" with big J's paradigm-locked cruft?

    Try becoming an expert at JS before bypassing it. Performance isn't it's chief asset, flexibility is. That's a tradeoff (and less of one due to much-appreciated JITs like Google's V8), not a language flaw.

    A functional, dynamically typed, highly event-focused language is a strong choice for the sorts of stateless http and multi-platform problems JS has traditionally had to confront.

    It's origins are undoubtedly goofy but Brendan Eich knew what he was doing when he opted to model it after Scheme, a functional language, and it did not become entrenched as the web's only client-side scripting language because client-side focused web developers simply don't know any better.

    JS's greatest strength is that it let's you establish your own app-appropriate paradigm even if that paradigm of choice is a clumsy woefully non-portable, non-modular, performance-murdering, illegible, specifically hated-on by the GoF patterns book as an antipattern class-cascade-inheriting waterfall model if you're just not comfortable architecting an app without a generous fist of ham to go with it. As a developer who's been exposed to C#, PHP, Python and yes I've even tinkered a bit with assembly, I am much more at home with C++ than I am with Java.

    ReplyDelete
  74. This is a great post, I favorited your blog and added your feed.



    iPhone softwareudvikling

    ReplyDelete
  75. looking forward to working something cool. here is forums to get together and share dart each other.

    Dart Programming forums: http://coderbin.com/dart/

    ReplyDelete
  76. I love the structure provided in there. Need to explore the inter-class (or widget if you will) communication aspects.

    Good show Lars.

    Ajay

    ReplyDelete
  77. it makes no sense ,if it does not overcome existing pitfalls. hope DART overcomes most of the existing complexities.

    ReplyDelete
  78. It's the same thing PYJAMAS does with python.. Compile Python code into javascript

    ReplyDelete
  79. Can this replace conventional JavaScript?

    ReplyDelete
  80. Why C syntax? Horrible. For a new language you should make the syntax look like Python or Scala. Everything else you can fix afterwards but not the syntax.

    ReplyDelete
  81. Notebook can be used for writing the codes and then save the codes in .js or .htm/.html. Run the saved file on any browser.

    ReplyDelete
  82. Dart is introducing concepts of OO to the client-web, when javascript along with closure tools already addresses these shortcomings. There is already great investments in terms of time and knowledge on JS. The closure library is awesome, code written in it is familiar to OO developers and coupled with the closure compiler is gives to lighting fast optimized javascript that 100% of the browsers out there understand.. if you had to bring in a VM based language for the browser, why not use Java, like its being used for android.

    ReplyDelete
  83. Hey, any body can reply ?
    Can it be integrated with GWT ?

    ReplyDelete
  84. I agree with Tnevzn, they are reinventing the wheel. Besides will it need a VM? Another one?Right... I'll stick with javascript, thanks.

    ReplyDelete
  85. So, for a newbie, what should we do, learn "java" first or "DART" ?

    ReplyDelete
  86. Have you guys planned in future possibility of compiling the statically typed libraries and programs directly to machine (native) code?

    That would really make my day! Prototyping with dynamic laxness and afterwards speeding up with native code by compiling.

    ReplyDelete
  87. This comment has been removed by the author.

    ReplyDelete
  88. This comment has been removed by the author.

    ReplyDelete
  89. hi,
    i understand that maintaining large javascript applications is a nightmare but i thought gwt has solved that problem :).

    please tell what was your motivation when designing new language? is cross-compilation from java less effective than from dart? or you plan to finally incorporate dart in browsers and treat cross compilation as short term solution -> but then, what is the future of native client?

    i really found writing javascript a pleasure, and knew it it is completely wrong for large scale apps to be maintained in long term. but i have seen it as best scripting langauge i ever seen. with extremely powerful and free js engine (v8 - thanks to You Lars :))

    but as to large apps -
    is something wrong with gwt that you needed dart? (as to maintainability of large scale business web applications)
    have you stopped believing in future of native client? (as to when performance really matters)

    regards,
    tomek

    ReplyDelete
  90. What is the diff between GWT and Dart

    ReplyDelete
  91. Best Wishes for DART, Is this language is similar to js?

    ReplyDelete
  92. I think programmers and engeneers should take off the fear of coding in JS. Congratulations for the new language!

    ReplyDelete
  93. An analysis of exactly how DART will improve on the current GWT approach would be much appreciated. We have developed very large apps using GWT and would be reluctant to move to DART without such an understanding.

    ReplyDelete
  94. good language, it is same js.

    ReplyDelete