“Google has released an early version of Dart, a new programming language designed to take some of the pain out of developing applications for the Web. But while it’s an evolutionary improvement on JavaScript, Dart faces a hard uphill battle for acceptance.”
Google Dart Unveiled: Farewell, JavaScript
41 Comments
Everybody says that Dart falls between Java and JavaScript. But to me – it looks quite close to C++. 99% of the C++ code I write can be trivially translated to Dart and a clever compiler should be able to optimize the result just as well as the C++ compiler. The most notable differences are with the memory manadgement and multithreading (isolates are nice, but different).
Generics look usable but, like Java, have nothing like the expressive, computational qualities of C++ templates.
Untyped classes/functions ARE templates, you just have to be carefull how you use them. For instance don’t call an untyped function if the compiler does not know the types of the parameters you call it with.
Edited 2011-10-11 08:33 UTC
Someone asked what exactly is the problem with Javascript that Google are trying to solve by creating Dart.
I would suggest that the answer to this question is that it wasn’t invented by Google.
And don’t forget — this isn’t the first time Google has tried this. We already have the Go language, which seems to be addressing a similar problem space.
Javascript has its flaws, just like any other language, but there’s nothing that badly wrong with it that requires launching a whole other language to replace it.
-
2011-10-11 7:41 pmsubterrific
http://www.dartlang.org/docs/technical-overview/#goals
I seem to remember reading in the announcement of Dart that it is being designed by the authors of V8 and other virtual machines to work around the problems encountered when creating an optimized VM for a language like Javascript that was created without the benefit of that knowledge. TL;DR; – Speed and memory overhead for mobile devices.
There are a lot of issues with javascript/ECMAScript. Javascript was designed with scripting html elements in a single page in a single thread. We’ve now created full blown applications, detailed library APIs, graphed on asynchronous requests. When you start trying to create actual applications in javascript, you start seeing major issues, like packaging, there isnt a real namespace system in javascript, so external APIs can essentially overwrite functionally without notification. The early days of JQUERY/prototype/mootools was horrible, adding jquery and prototype to your site would have unexpected results, (prototype had features that overlapped jquery s) While javascript libraries are attempting to play nicer with each other (there are emerging coding standards and best practices that didnt exist 5 years ago)…but there is no language enforcement, which sits badly for some companies who create software at the “enterprise” level, that needs better assurances in stability and way more deterministic.
Threading and concurrency is another issue, though browsers are trying to fix this, firefox has webworkers…but again, its not a language thing.
The list goes on, javascript just isnt up to the task for the modern web. There IS a proposal out there to get javascript up to snuff (Harmony i think). Think of Google’s Dart as a contingency plan just in case the ECMA process goes crazy again and everyone is held hostage for years (just look up javascript/ECMAScript 4 and why it was abandoned after years of work). Google is dependent on javascript/ECMAScript. Heck, Javascript is Google’s lifeblood. It makes sense that they wont leave anything up to chance.
Edited 2011-10-11 12:23 UTC
-
2011-10-12 5:25 pmLennie
Yes, there is a small possibility of clashing at runtime of variables.
But most of them go away as long as you make everything private:
http://javascript.crockford.com/private.html
JavaScript doesn’t really need concurrency as everything is already async./event based.
The existing real problems are probably things like support for decimals. Obviously Crockford explains it here:
http://www.livestream.com/etsy/video?clipId=pla_1463e546-47ed-4a93-…
And how adding extra features to browsers because of compatibility with old browsers. But that problem isn’t solved by Dart either. Any mistakes that get introduced in Dart will probably be in that language forever (or atleast for a very long time) too.
It is really stupid from Google to want to introduce something new if the current ECMA process is working correctly. They are actually undermining that.
I’m hoping Dart isn’t going to replace JavaScript so much as place a layer of improvement over it. JavaScript is pretty good at what it does, when used properly. And Dart can compile code into JavaScript. I think this opens the door for larger, more complex applications to be written in Dart and then, optionally, run in environments that already support JavaScript.
VM Based, JIT, embeddable, type safe, very permissive license (unlike Java or Mono). I can see this taking over mono as the “scripting” language of choice.
-
2011-10-11 2:16 pmslashdev
Just out of curiosity whats the difference between Mono’s license (MIT/X11) and Dart’s License?
-
2011-10-11 9:56 pmreduz
It’s not MIT/X11, read: http://www.mono-project.com/FAQ:_Licensing
LGPL does not allow embedding in, say, a PS3 game. Engines that use mono (like Unity) purchase special commercial licenses.
-
2011-10-12 3:38 amSlambert666
LGPL does not allow embedding in, say, a PS3 game.
What on earth are you talking about? LGPL does in general (unless static link exception) not allow static linking into a non GPL program, that’s it.
So LGPL does allow embedding into a PS3 game, commercial software. What they write is:
Mono is available to be licensed commercially if the LGPL/GPL/X11 combination is not suitable for you. Xamarin offers commercial licensing options to redistribute Mono under non-LGPL terms. If your organization intends to redistribute software which embeds or bundles Mono, but is unable to comply with the terms of GNU LGPL v2, the Ultimate Edition may be right for you.
-
2011-10-12 6:52 amreduz
You are forgetting two issues here.
1) Dynamic linking is usually not available on consoles/phones/etc.
2) Console developers explicitly forbid GPL licensed stuff into games (Nintendo).
So no, you can’t use LGPL stuff there.
-
2011-10-12 5:29 pmLennie
1. I would know about that.
2. It also depends on the version of LGPL. LGPLv3 doesn’t allow patents and has some clauses are trying to prevent “tivoization”. But LGPLv2 is a lot more friendly.
-
2011-10-11 8:42 pm
No, seriously; am I the only one who keeps misreading the headline as “Google Fart Unveiled?” If so, what a way to kill JavaScript.
There’s absolutely nothing that I can see from Dart that would make me want to touch it. At all. Bye Dart, we never even met. Hi Javascript, old friend.
Anyone building a website needs to have it work for 95% of their users. So even if dart is implemented today in FF and IE it will still take years before anybody can actually develop a site knowing that their users will be able to use it. So I wouldn’t run out and start learning it just yet. We have time. a lot of time.
Oh, just look into the source code – AllThisLongOldSchoolAproachLetsAddEvenMoreHereToMakeItEvenCooler ๐
https://gist.github.com/1277224
What ppl seem to depreciate, is, that the popularity of the language might not be defined by thier uber-cool features.
As for me,I don’t like this JAVAish syntax. Well anyway – ppl never learn. Programming should be for ppl, not robots or PhDs needing to feel they finally can utilise their college uber-knowledge.
JavaScript, Python – much more readable. And Google has Guido on-board. If Dart is supposed to replace JS, I wish it follows Google Wave route ๐
Main problem with Dart is that it’s not an evolutionary improvement on Javascript, it’s an all new Virtual Machine.
So, none of your old js code will run with your new Dart code.
IMO, how google should have implemented this would have been to add optional type tracking in their v8 js engine optimization paths, and provide a thin frontend that turns dart language to javascript + extras.
This way, you could intermingle Dart and JS code freely.
I am a bit underwhelmed about Dart because google took this route. We already have CoffeeScript that is a great language that directly maps to JS code (but eliminates “function” keyword, has list comprehensions from python, has classes, etc.). CoffeeScript works seamlessly with JS code – can run it, can get run by it.
Hmmm… I do think it’s a bit of a weird sell – that is to pitch this as a JS replacement but as an application language it’s not too bad (I’ll admit I haven’t _really_ dug into it).
Standard sort of class/interface stuff going on. Generics look usable but, like Java, have nothing like the expressive, computational qualities of C++ templates.
Given the more rigorous type engine I’d expect faster code execution than JS too – probably less type/method searching going on.
However, 10 out of 10 for “isolates”. They seem to have a solid memory and process model but have made the message sends “invisible” – that is a method invocation becomes a message send. The doc I read didn’t go into a huge amount of detail on the actual implementation (are objects copied as they go across the process boundary or have they implemented a binder/ref count system with (maybe) CoW)? Simply hiding the implementation this way is good enough.
As an application programming language I wonder if it was a better use in Android? It can’t be _too_ hard to port Java code to Dart once the libraries are put together and lets Google stick 2 fingers up to the over inflated ego of Mr Ellison.
Maybe getting it into browsers (even if only Chrome) is a good way of getting an implementation into developers hands.
If I understand correctly it is possible to translate Dart into Javascript. Please look at Point 3. in this file https://code.google.com/p/dart/source/browse/branches/bleeding_edge/…
Yeah I saw that too — doubt it can use existing javascript libraries though – which is neither here nor there, I suppose. If the project were to succeed, in time we would see dart libraries created to fill the void. In that case, we could write in dart and convert to javascript for browsers which don’t support dart natively.
The ability to code in Javascript isn’t being removed for sometime yet, that would be stupid. most sites these days incorporate some javascript so they wouldn’t remove the ability to parse it for some time yet. All that dart is is a more senseible language for creating web-applications on, which is possible in javascript its just a pain
Well, the main reason why I use Js libraries is because they make up for things that JS is missing. If dart already has them built in, then my use cases for those JS libraries is greatly decreased.
They are planning on modifying GWT to output dart at some point as well, and have hinted at a 100% dart version of it ( dart running on server, dart running in client).
Check out what Dart “Hello World” looks like when compiled to Javascript:
https://gist.github.com/1277224
No kidding.
CoffeeSctipt, OTOH, maps to JS quite directly.
Only 17,259 lines of code. I can write that in less than a week. :-O
Well Dart really is not supposed to be translated to Javascript to begin with. Once it’s got its own VM on chrome I’d expect it to be lighter and faster than JS.
I think the point is that you will then run the output of Dart through the Google Closure compiler. In that way all the extra cruft is stripped out.
ClojureScript does the same thing. A stock “unoptimzied” “Hello World” is pages and pages of standard library functions, but it is also designed to run through the Google Closure (no j in this case) compiler and have all the dead code removed. After that, you’re left with a very compact optimized file.
I think that is exactly why Dart, or any other full replacement for Javascript, is so tempting.
Javascript sucks a lot more than it should, which is why people are always trying to make it easier with things like jQuery and CoffeeScript. I think there is a great amount of merit to completely ditching the old and bringing in something new.
The fact that CoffeeScript is ok means you don’t need to ditch js to get tolerable language.
Just add optional type definitions to underlying js engine, and you can use a better language like CoffeeScript and have the code run fast, while retaining compatibility.
My point is that sometimes great things come from breaking compatibility. As nice as it may be, CoffeeScript is still just a crutch.
“not created here” syndrome i guess
Depends on the viewpoint, some don’t like CoffeeScript because it doesn’t have a ‘let’ or a ‘var’ for local scope and I guess that it has JavaScript view that “all number are floats” on this point I prefer Dart’s big ints.
Python and Ruby do just fine without let or var for local scope.
As for numeric model, CoffeeScript has no choice. It uses what Javascript provides, that’s why it can be translated so directly to JS. It’s a small price to pay for not needing a whole new Google specific VM.
JavaScript is the assembly language of the web. Dart is one of the many projects trying to build the C language of the web.
Edited 2011-10-14 14:24 UTC
So if this language takes Python as its role model and can be compiled to Javascript, why not just code in Python and use pyjamas?
http://pyjs.org
I ask this out of curiosity, as someone who does not do any web programming. I am interested in it, but I don’t want to have to learn one language on the client (javascript) and then another for the server (php/perl/etc).
There is not much python in it.
It looks more like a simplified C# and it looks like it has the functionality of Script#, except for less browser support and less tool support.
But it is still early days and it does look very promising.
Although I do some light JavaScript work, I never really spent the time learning the language expecting that one day it would either 1) be Replaced, or 2) improved upon.
So we have JQuery which is an improvement on the language, and now some alternatives such as C++ in the browser and this.
Though… close to every language (among those in active usage) one day will be either 1) Replaced, or 2) improved upon.
Maybe such is the reason for lots of (supposedly) shoddy JS around – enough people doing what you did / not bothering to learn its idiosyncrasies?
The code samples looked a lot like javascript with some new foundation class names.
I imagine that Dart will follow the same way as Google Wave.
We already have several compilers for current languages that compile to Javascript, why take a complete new language?
For me this is a kind of disappointment.
Free Dart Language ebook;
http://www.heronote.com/files/Dart.htm“