General musings on programming languages, and Java.

Monday, October 22, 2007

Life in the old Java yet - Closures Prototype

I get home from eating some overpriced underportioned seafood, and drinking a few stouts, phone my girlfriend and check my email. Nothing out of the ordinary, nothing interesting.. but wait! An email from Neal Gafter with a closures prototype! Wow!

So I download it, follow the instructions and it fails. Hmm. I'll try on Linux. javac -version works. I write my first working Java program with closures. I write my second! I mention it in an IRC channel or two, excitedly! I remember that I'm still on the phone and have no idea what she said for the past 5 minutes, so I lower my laptop lid. I get off the phone as quickly as possible, which is to say we talk for another half hour, which is to say she talks for another half hour.

An hour or two after that I send Neal a list of about 5 or 6 problems with the prototype, but go to bed happy, especially having drunk a Spitfire. A beer, not a WWII aeroplane.

First thing in the morning, he's fixed the problems, so I download again. The same problems are there. Hmm. Oh, right, the filename included the date. What's today's date (it was 2am today that I sent the emails)? 2007-10-22. But Neal's in America, and they're backward, so 2007-10-21. Ok, got the right file now. Still fails in Windows, and at least one of my reported failures still fails but for a different reason. I start playing again, and some more code fails for the same reason as the first, so I give up for now.

There's much more fun in breaking a prototype compiler than a production one!

Ok, new day, and I'm at my girlfriend's house for the evening. Neal's just sent another prototype, and it still doesn't work in Cygwin. I can't get my laptop online to connect to Eugene Ciurana's Linux box that I was testing on, so I start looking at the bin/javac script. I see and fix the not-on-Windows problem. It's passing a full path to lib/javac.jar to javac, and that includes /cygdrive/c, Cygwin paths, which Java doesn't know about. I find a fresh batch of bugs and surprises. After finding the same bug twice from unrelated pieces of code (and getting pestered to watch a film) I stop trying. Neal confirms the bugs, but nothing new arrives the next day.

Over the next few days I find more and more bugs, and Neal fixes them all. There are a few bugs that turn out to be features; they're actually in the spec that way.

Now that I have a fresh set of bugs waiting to be emailed to Neal, he's just published the closures prototype. You can find it over at his blog.

I'll shortly publish some surprises from playing with the prototype, then some examples of what you can (and can't) do with it. In a less commentative style..

5 comments:

Anonymous said...

Very cool that there's finally a playground. I also noticed a few unrelated improvements showed up, such as multiple exception types for a single catch block.

Of course, true playing can't happen, in my opinion, unless at least one major IDE supports them. I don't normally program in a non-intelligent development environment, so the annoyances of not having the bells and whistles precludes anything but toy problems and gets in the way of a fair comparison in the first place.

Still, rome wasn't built in a day. This is great news!

(Yes, still a CICE fan, but since our last email conversation I'm far less convinced CICE is the better proposition).

Ricky Clarkson said...

Recently I've been programming in emacs for my work and I've been using vim for this project. I think I need to tweak IDEA's settings to make it usable again.

Anyway, my overall thought is that if you wait for the IDE all the time you're slower to innovate and less flexible than you might otherwise be.

vim has great support for this syntax. Its default colour file for Java flags => as an error, which is fine, because it doesn't seem to get confused by it.

JP said...

Rick,

Good post.waiting for your additional articles about closure prototype.

Thanks
Prashant Jalasutram
http://prashantjalasutram.blogspot.com/

Brian Oxley said...

You don't say, but I take it you're familiar with the $(cygpath -m $unix_path) [or -w, YMMV] trick to Window-ize the paths for Cygwin.

Ricky Clarkson said...

binkley,

I wasn't familiar with that. I just edited the bin/javac script, making the lib/javac.jar link relative instead of absolute.

Thanks.

Blog Archive

About Me

A salsa dancing, DJing programmer from Manchester, England.