The Source for Java Technology Collaboration
User: Password:



Tim Boudreau's Blog

Open Source Archives


What if we built Java code with...Java?

Posted by timboudreau on January 30, 2008 at 01:36 PM | Permalink | Comments (23)

My friend Jon had an interesting insight: Both Ant and Maven rely on lots of XML. XML is good for describing data and terrible for describing behavior. A build is mostly behavior. What if, instead of tormenting Ant into iterating on a bunch of subprojects of subprojects, if we just used an actual programming language to write build scripts. Like, oh, say...Java, for instance?

So he created the Gosling project. It's pretty embryonic - and I think some of the file and resource classes could be replaced by straight usage of things like javax.tools.FileObject, but it has a nice simplicity. Here's the constructor for Gosling's own build to build itself. It has a similar feel to what Jon did in designing Wicket's APIs:

    public GoslingProject() {
        final Folder root = new Folder("/Projects/gosling/workspace/gosling");
        final Folder source = root.folder("src");
        final Folder lib = root.folder("lib");
        final Folder target = root.folder("target");
        add(new JavaApplicationBuilder() {
            @Override
            protected Set getDependencies() {
                final ResourceDescriptorSet dependencies = new ResourceDescriptorSet();
                dependencies.add(Apache.apache.wicket.core.development.resources());
                dependencies.add(Apache.apache.wicket.extensions.development.resources());
                return dependencies;
            }

            @Override
            protected Set getJars() {
                return lib.nestedJars();
            }

            @Override
            protected Folder getSourceFolder() {
                return source;
            }

            @Override
            protected Folder getTargetFolder() {
                return target;
            }
        });
}
Brazilian Salt Shakers I spent last night wrestling with writing an Ant script to build, test and build Javadoc for an ad-hoc collection of projects, where a bunch of custom information needs to be gathered from the projects and embedded elsewhere, and I just found myself thinking this is so not the way to build software!.

I mean, the appeal of things like Ant is that many things are built in a pretty similar way; Maven is even more "my way or the highway" in that regard. I use (and sometimes like) both of them. And in theory an Ant XML script (xml script - now there's an oxymoron) is human readable - although I challenge anyone to make heads or tails of this in ten minutes. It certainly beats Make and tab vs. space madness. There's an argument that it's toolable - that a tool can analyze an Ant script. This seems to me to be a red-herring if you do a design like Wicket or Gosling use - where you know that the entire state you need to analyze is going to be set up in the constructor of a known class of a known type. The Javac Tree API may not be for the faint of heart, but analyzing the closure of a constructor is perfectly doable.

My point is that Ant doesn't really deliver the clarity it promised except in the most trivial of cases. You could have at least as much clarity with plain-old Java code - you just need to start from a good design so the code can speak for itself. And a design where all targets will be added to the build in the constructor is pretty darned clear. Isn't one of the things the agile crowd talks about a lot letting code speak for itself?

Not to mention that running javac in-process ought to be blazingly fast. And that such a project could import and call existing Ant tasks to do things with a thin adapter layer - so anybody's custom tasks or missing functionality could be handled leveraging stuff that's already out there.

It seems like a pretty nice idea to me.

Everett Hafner, a belated eulogy

Posted by timboudreau on January 12, 2006 at 11:30 PM | Permalink | Comments (3)

I was just reading Richard Feynman's essay Arlene, about the loss of his wife - written with a combination of wit, love, seriousness, practicality and a real sense of loss. That and another conversation and it made me think of one of the most fascinating people I ever knew. I write this in his memory, because to this day he lives in my memory, and I know I am not the only one.


Sometimes you meet someone who ends up influencing your life and thinking in subtle but important ways. Everett Hafner was an eccentric, brilliant man who left a legacy in the lives of many of his students, and I was one of them.

In college I took Electronic Music. My TA was Everett. I had to pass an interview to enter the course. My music reading was abysmal, despite having perfect pitch - when I took piano, it was always so easy to memorize what I had to play that reading music never sunk in - I'd play it once and then study the notes when I got lost, until I didn't get lost anymore. My music teacher finally bagged me, noting that my my mistakes were always "musically correct". That left me fantastically underprepared for a grad-level music course as a freshman.

Most professors would have booted me out the door; Everett asked me to hum intervals and probed my ability to understand music and arrange - he actually was interested in my native ability, not formal training, and just took an unorthadox approach based on my mental model for music, rather than the formal model of written western music. I hummed intervals. And he let me into the class. It's rare to meet someone with the interest and the ability to intuit how someone conceives of a topic, and then measure their ability through their conception of it, instead of simply measuring their amount of formal training, which is much less work.

Everett was a physicist, and had been one of the designers and founders of Hampshire College in the 60's, and was dean of sciences until his retirement, already in his 70's I believe. At which time he decided to get his PhD. in music at UMass and learn to fly planes. That alone I admired - and hadn't encountered before. Here's a man in his seventies getting his pilots license and a PhD. in a discipline completely unrelated to his former career (though he had been a pioneer in electronic music in the 60's). Seeing him changed what I could imagine for myself as I get older.

He was eccentric - I don't know if he owned a car, but he often needed a ride home to Williamsburg after class, and so we got to talk for the forty minute ride - I lived in Northampton, Mass., so it was only a little out of the way. Once he asked me if I wanted to "go up" in the plane, but I declined - somehow I thought I'd be imposing. Despite what would later happen, I wish I'd said yes. A few times he invited me in, and we would talk about music theory, or unrelated things - and always in the middle of a conversation, he would simply say "Well, run along now..." - I was dismissed. He had this giant light bulb, manufactured in 1919 and still working, mounted with a giant transformer in the electronic music studio. A former colleague of his, and father of a boyhood friend, once told me "Everett has ten ideas a minute, and half of them are bad."

Some stories I remember:

  • Someone commented on something political in class, and he responded "You cannot be in a situation you don not choose to be in." Arguments of all sorts of horrible things were brought up as suggestions for situations you can't possibly choose. He just stuck to his guns and repeated the statement with infectiously complete assuredness. I'll never know what precisely he meant by it, but that moment and phrase has been rattling around in my brain in the decade and a half plus since, and it is the most empowering way to bring yourself to understand that you can bring yourself out of adversity. I wish I had asked what exactly he meant.
  • He was the man behind setting up the science labs at Hampshire College at the time it began, with no walls or divisions - all disciplines should work in the same building or room, so people communicate and synergize, rather than being isolated specialists. And, as he told it to me, one of the big rules was that there would be no locks on the equipment lockers. He claimed that the whole time he was dean, there had never been a theft. And that one of the first things that happened after he retired was, they put locks on the lockers. And the very next day had their first theft. I will always remember that as a lesson in the communication value of things like locks and fences - that they are as much an invitation as an impasse.*

    *(It was that story and the thinking behind it that inflenced me to argue strenuously against segregating NetBeans CVS permissions by project, but instead to continue our original practice of giving all committers permissions to write to the entire repository. I lost that battle.)
  • We spent one entire electronic music class (in which, oddly, there were six students, four of whom were named Tim) discussing his theory that intelligent life had to evolve on Venus before it evolved on earth (it centered around some synchronicity between the earth's and venus's moons' orbits)

What I admired most was his open mind and ability to think way out of the box. And that in his seventies, he was more alive than many people I knew in their twenties, engaged with the world and interested in new things. I pray I am so lucky.

In the fall of '99, when I was working in Prague, I googled his name - hoping to find an email and reconnect. And found his obituary. He'd died in a plane crash, flying his Cessna. I cry rarely, probably too rarely, but I did at my desk that day. He was such an ageless presence that it was impossible to imagine him gone - it is to this day. And it was also for him. He died doing something that he loved. Having seen family members go slowly and painfully, I hope that I die doing something I love.

So I write this today, because I find after all these years, I still mourn Everett Hafner. And googling, I was surprised to find out how many others had similar things to say and fond memories. I'm sure some of the fifteen year old memories I've written here are off in the details, but not in the essence.

For the subtle influence he had on the course of my life and my thinking, I can only say a, far too late, thank you.

NetBeans now has Mac-friendly key bindings

Posted by timboudreau on September 08, 2004 at 01:37 PM | Permalink | Comments (7)

I just committed some changes to NetBeans key bindings handling, so that mac users will get key bindings that are much more like other mac apps (no change for Windows or Linux users).

Specifically what's different:

  • Ctrl -> Command - everything that normally maps to Ctrl will use the Command key instead, except where that's impossible (Command-H always hides the app, Command-Q always quits, Command-~ always changes windows, that sort of thing)
  • Command-G maps to Find-Next
  • Command-R maps to Replace (Ctrl-H, the windows key binding, works as well)
  • Cursor control keys in the editor are the default mac ones - Option-Left-arrow to skip to next word, etc. (Option==Alt)

Also, dialog buttons will now appear in the correct order on Macs, with OK on the right.

Alas, these changes will not be in NetBeans 4.0 Beta 2 - I missed the cut-off, but it's better to review things properly than to rush. They will be in Beta 3.

Please give it a try, and let me know if any of your habitual keystrokes are doing the wrong thing. You can download tonight's build here. Be sure to select "Daily" from the "Build Type" drop-down.

The build with these changes will become available just after 4PM PST, or 1AM GMT.



Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds