Monday January 08, 2007 There's lots of fun to be had playing around with javac. I've never been real happy with debates about language features, I'd much rather implement them and try them out. For example, over christmas, Rémi Forax did an implementation of the ":=" declaration syntax, along with some other type inferencing touches. [I used to give myself an annual christmas present: I'd do a "Christmas hack" that was just for fun... That ended when children entered the picture. My Christmas hack was fun, but children are better]
For years I've wanted to set up a "Kitchen Sink Language" website for experimentation. A place where people could throw language features, no matter how absurd, just so that folks could play around. Now that javac has been open-sourced, it's easy. Peter von der Ahé beat me to it and built the site, but he hasn't quite got it ready yet.
Playing with javac is particularly easy since it got repackaged as a NetBeans extension. It's an odd but slick way to make it easily available: when running NetBeans 5.5, go to the update center. You'll find a javac project tool... Download it and create a javac project. It gets pre-populated with all the sources of javac. Lots of fun.
Even if you don't want to create a new language extension, installing the javac sources is interesting if you like studying compilers. It's a particularly nicely written one. No, I didn't write it: I wrote the original java compiler, which was a C program. It has thankfully been dead for years.
If you're into extreme sillyness, you can rewack the parser completely so that it will compile other languages. Several years ago I actually wrote a Fortran parser on top of javac - it was good enough to compile LINPACK, but not much else. I did eventually come to my senses and throw it away.
Another thing you can use javac for is dropping code into it that studies the parse tree. I like to do that
when analysing language features: come up with a tree walker that looks for things that could be rewritten to
use a proposed new feature. Rather than using javac, you can play with Jackpot in NetBeans to get the same
capabilities (Jackpot is really just a UI for the AST). It's pretty depressing how few new language features improve more that a thin
sliver of code. One of the reasons I like ":=" and operator overloading for [] to map to container classes is that
they simplify visual clutter all over the place.
Permalink
Comments [12]
Posted by Steve on January 08, 2007 at 01:56 PM PST #
I welcome the addition of shorter syntax for both variable declarations and maps. With regard to variable declarations I have suggested:
Which are equivalent to your suggestions of:
The reason for proposing the use of keywords is:
Posted by Howard Lovatt on January 08, 2007 at 06:26 PM PST #
Posted by Rael on January 09, 2007 at 08:12 AM PST #
Posted by barspi on January 09, 2007 at 08:54 AM PST #
Sun should stay in control on the language feature, but others may vote for there favorite language feature.
Giving everyone control over the languages features is a bad idea and may lead to the end of the langue.
Welcome to the dark side of open source.
Posted by Evert Tigchelaar jr on January 09, 2007 at 11:06 AM PST #
Posted by Tom Palmer on January 09, 2007 at 12:19 PM PST #
Posted by Bharath R on January 09, 2007 at 11:51 PM PST #
Posted by Jesse Kuhnert on January 10, 2007 at 11:06 AM PST #
Posted by 220.225.127.31 on January 10, 2007 at 08:19 PM PST #
Posted by Frank Wilhoit on January 11, 2007 at 12:28 PM PST #
Posted by John Cowan on January 13, 2007 at 08:22 AM PST #
Posted by Dongan on January 13, 2007 at 07:01 PM PST #