Dart compiler in dart

153 views
Skip to first unread message

Jim Hugunin

unread,
Oct 24, 2011, 6:12:02 PM10/24/11
to mi...@dartlang.org
Olov's thread brings up an excellent question about language tools for dart written in dart - along with some impressive early work in that direction.  To answer his primary question:

Yes, we are working on building a complete dart compiler in dart.  If you would like to see the current very early shape of this code you can find it here:

Short history:

I've spent the past ten months working as the tech lead on a project to build web applications on top of the emerging dart language.  This has been a great education for me about how the web works and a wonderful opportunity to help drive this language and tools to be great for actual app developers.  I'm very proud of the swarm application that we built both for its beautiful UI and for the way we were able to drive the initial uncertain phases of the language and tools based on concrete development experience.

However, an interesting thing happened over the past 10 months.  Dart has matured enough to be fun to develop in.  As I started to enjoy coding in the language more, one day, about three weeks ago, I decided to try to write a dart compiler in itself.  Yes, I am one of those odd people who sometimes decide that the most fun to be had on a rainy Sunday is to write a compiler for a new language.  This particular Sunday turned out to be one of those glorious beginnings of a 48 hour coding binge that led to an initial barely usable dart compiler in dart.  

I've spent most of my career trying to end the battles between the dynamic and static worlds and instead bring them together so that each side can enjoy the benefits of the other.  Writing this compiler in dart is the first time that I've really felt the effortless blend of these worlds that I've been seeking.  In the past, I've always written the first version of a compiler in a dynamic language (usually Python) in order to enable rapid experimentation and avoid premature commitments.  However, when the structure was sufficiently solid, I would always move to a more static language (usually Java or C#) in order to better support a larger code base with more contributors.  Dart is the first time that I have been able to start off writing code in a very dynamic fashion and incrementally add static checks as designs become solid or complexity warrants the effort.

Over the past three weeks, I've taken this very rough prototype forward - with the help of several other outstanding compiler developers.  So far, it has scaled exactly as I would have hoped with the value of explicit interfaces and other types showing itself at points of interaction - but not really being required on the insides of well-defined modules.  We've made a lot of progress on this compiler already and feel that it is time to get it out into the open.

This compiler is roughly three weeks old.  It has some nice properties with self-hosting and generating moderately readable JS output.  However, it is currently only passing two-thirds of the dart test suite - and a quick grep for TODO in the code base will show you how much is left to be done.  If you like to live on the bleeding edge, feel free to take a look and give us your feedback.  If you'd like something more stable, please keep using our more mature tools.

Thanks - Jim Hugunin

Olov Lassus

unread,
Oct 25, 2011, 2:35:35 AM10/25/11
to Jim Hugunin, mi...@dartlang.org
On Tue, Oct 25, 2011 at 12:12 AM, Jim Hugunin <jim...@google.com> wrote:
> Olov's thread brings up an excellent question about language tools for dart
> written in dart - along with some impressive early work in that direction.
>  To answer his primary question:
> Yes, we are working on building a complete dart compiler in dart.  If you
> would like to see the current very early shape of this code you can find it
> here:
>   http://code.google.com/p/dart/source/browse/#svn%2Fexperimental%2Ffrog

This is great. I kind of hoped that the team had an internal parser
prototype ready to be released and this is much more than that. The
scanner port didn't take me more than a day so I'll gladly put that to
rest, especially now that I don't have to create and maintain another
parser. It was also a useful learning experience in terms of mapping
Java to Dart.

Thanks for sharing your history and experience with writing code in
Dart, I enjoyed reading it. I've followed your work since the early
Jython days and am glad to see you involved in Dart.

> This compiler is roughly three weeks old.  It has some nice properties with
> self-hosting and generating moderately readable JS output.  However, it is
> currently only passing two-thirds of the dart test suite - and a quick grep
> for TODO in the code base will show you how much is left to be done.  If you
> like to live on the bleeding edge, feel free to take a look and give us your
> feedback.  If you'd like something more stable, please keep using our more
> mature tools.

I think you meant that it is only failing one-third of the dart test
suite. Seriously, this is really impressive. Thanks again for
releasing early. Now you'll have to excuse me, I've got some code
reading to do.

> Thanks - Jim Hugunin

/Olov

Reply all
Reply to author
Forward
0 new messages