Ever since it was announced that Dart would be announced at GOTO conference I’ve been wonder what dart would be like. I thought I’d take the time put down my initial thoughts here.
Is there a need for another language?
Tim Anderson poses the question nicely here, so I thought I’d have a stab at answering it. There are a lot of programming languages in the world, so there would seem to be limited space for a new one. However, I think Google are creating this language for two reasons:
2) they want to get themselves and others off Java.
Those are two fairly bold statements, so I’ll try and justifier them, taking each in turn.
To try and justify the second statement: it’s fairly well document that Google uses a lot of Java internally. It’s also fairly well document that Google are having a big spat with Oracle, the new owners of Java. So it’s not a great leap of imagination to think that Google would be interested in moving away from Java. Problem is where would they go? Clearly C# is out, as Google detest Microsoft as least as much as they do Oracle. So while there is lots of other languages out there they could use, there’s nothing out there that really leaps as the Java replacement (at least if you don’t want to go with C#). So my guess is that Google hope to sweep up programmers who are unhappy with both Microsoft and Google as well as get themselves off Java.
What is Dart like as a language?
Well for me it’s a disappointment. I guess the biggest disappointment is that the basic unit of code is a statement, rather than expression, meaning it is an imperative rather than a functional language. This is a fundamental design choice that can be altered, the rest of the remarks I’m going to make probably could be fixed in one way or another but this can’t be. So why might it have been a good idea to make the language expression orientated rather then statement orientated? Well much of the progress in modern object orientated programming has been inspired by functional programming, here I’m think of Linq and jquery as the prime examples but there are probably others. While these frameworks work well, they are somewhat limited by being built on top of statement orientated languages. For example one of the criticisms of Linq I hear most often is that Linq queries often end up being monolithic blocks that are difficult to pull apart and once they get bigger than, say, five lines, they become very difficult to understand. I’d contrast this to F# pipeline expressions, basically the equivalent, but in an expression ordinated language, which are easy to understand and to pull apart and refactor.
Apart from being imperative, Dart also seems very conservative, lacking useful features. This is not that surprising for a first cut of the language, but all the same, there’s nothing that leaps our and says use me for your next project. The things that I’d like to see that are missing are (and admittedly I haven’t spend as much time as I’d like looking at the language as I’d like so I could be wrong on any of these points):
- Tuples and currying. These greatly improve compositionality in a language, although it is good to see there are functions as first class values
- No immutability. And unless I missed it way to declare a value as being read-only, let alone nice a nice easy way to create a modified copy of a value.
- No pattern matching. Just makes so many difficult problems easy, hard to see why you wouldn’t put it into a language.
One good choice I think they made is that all concurrency must use actor model type mechanism called isolates. However, I do have one small quibble with this. With no immutability in the language how will they archive this isolation? Surely the actor will leak references all over the place. I could be wrong, but I strongly suspect this has been fixed with lots of fairy dust.
Google have said they are hoping for “rapid evolution” of Dart so it will be interesting to see what features do get added.
What is Dart made of?
As Dart is open source I thought it might be nice to peak under the covers and take a look at what dart is made up of. Once past the fairly broke process of installing depot_tools, so I could check out all the sources, it was fairly easy to do this using, yes you guessed it, an F# script. But before we dig into the numbers it’s probably best take a look at the top level of the source tree (only give a comment where it doesn’t seem obvious what the directory is for):
- client – a set of development tools for Dart
- corelib – the core library for Dart
- editor – (presumably, as there’s no read me) an editor for Dart
- language – a parse based on antlrworks
- tools – not sure what this is about, seems to have some build stuff and syntax highlighting for vim
The file type counts are:
If we exclude the third_part directory:
So we can see Dart is overwhelmingly written in Dart. Notable exceptions to this are the runtime directory which seems to be all C or C++ and compiler and editor which are java. The compiler readme file does contain a vague hint that it’s just a '”placeholder”, so presumably it’ll be bootstrapped at some point. It’s also worth noting that that third-party dir does seem to contain some stuff which isn’t actually used, for example I can see, closure_compiler_src but no evidence of Clusure being used.
Feedback was imported from my only blog engine, it’s no longer possible to post feedback here.
re: Some thoughts about Google’s new Dart programming language - Art Scott
Knowledgeable and perspicacious.