Monday, May 22, 2006

Keynote Demo Explained

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

As mentioned previously, Project Semplice (Visual Basic for the Java platform) was unveiled at JavaOne, both with a technical session, as well as a keynote demo during the technical keynote. The video stream of the broadcast is available - choose
high bandwidth or
low bandwidth.
This is the third part of the keynote, and the Semplice segment begins at around 10:40, where Graham presents the intro slide, and lasts until about 14:40. If you have time, you should check out all the keynotes.

The audio comes through well, but it's hard to see the screen in the video. So let me show you the code in more detail.

I built a temperature converter application, converting Fahrenheit degrees into Celsius. To do that, I dropped three components: a textfield, named fahrenheit, a button, and a label, named celsius.

I then added an event handler to the button click event, which will convert temperatures according to the standard formula:

celsius = (fahrenheit - 32) * 5/9

To motivate why BASIC can be attractive, especially to new programmers, I showed what we'd write in a standard Java application utilizing the above JSF components:


I agonized over what code to write here. I personally don't like to use the trick with ""+ to cause integer to String conversion; the code I would have written is using Integer.toString(int):


But I'm not out to try to make Java look bad! And given that many people do use ""+, I went for the shorter solution. There is of course another possibility I could have used, which may be more true to the spirit of JSF. I could have dropped an IntegerConverter on the textfield. I could then have written code like this:


but as you can see this is not simpler than calling Integer.parseInt() directly - and it adds more complexity to the demo. (auto-unboxing might eliminate the need for the .intValue() call but you'd still need the cast, and that alone is a showstopper for "newbies".)

So the next step was to write what the equivalent code looks like in BASIC. Here it is:

celsius.text = (fahrenheit.text - 32) * 5/9

Notice that this looks a LOT like the original formula. In fact, at the end of the demo I actually comment out the above line and uncomment the original line - and that's the code I compile and deploy!

As I mention in the demo, there are several interesting things to note here.

  • The BASIC code is extremely simple. In this particular instance, Java looks complicated. There are two reasons why the BASIC code is simpler.

    • First, it performs a lot of automatic type conversions. We're mixing strings and numbers here, and the Right Thing happens. Strings containing numbers get parsed into numbers, computations happen, and when a String is needed it's generated from the numerical result.

    • Second, we're able to access Java class properties using simple property syntax. Instead of calling celsius.setText(), we're
      writing celsius = , and the right hand side expression is fed into the setter. Similarly, we can refer to the getText method of the textfield by simply referring to it by its JavaBean property name.

    Java is more strict in which type conversions it will allow. "Automagic" type conversion can be dangerous. In Java you frequently get compiler
    errors or warnings if you do something that is probably wrong. In BASIC you won't notice until runtime - and hopefully it's not a rare scenario that
    goes undetected until a customer runs into it.

    A classic example of this happens in C, where any number is converted to a boolean when
    needed - nonzero is considered true, zero is considered false. If a programmer writes int x = getFoo(); if (x = 50) { ... }, Java would complain, because the if statement evaluates to an integer rather than the expected boolean (notice that it's a single =, not ==). In C, some developers like to
    take advantage of this "expressiveness", but it's usually a sign of a bug.

    Even in Java, where typing is pretty strict, you can run into trouble
    with some of the automatic conversions. For some great eye openers, read Java Puzzlers! See Puzzle #1
    in the sample chapter for example.

  • We're calling into Java classes from BASIC! The celsius and fahrenheit references point to Java objects that are instances of JSF UIComponent classes, written in Java.

  • We've written an event handler (attached to the button event) in BASIC. This event handler is being invoked from Java code (the JavaServer Faces web framework). Thus, we have Java calling BASIC calling back into Java.

  • The reason I could uncomment the original line, the one which doesn't specify the text property of the textfield or labels, is that
    the compiler also understands JavaBean default properties. If you leave out the property, it will look at the default property (which these JSF components specify in their BeanInfos) and use that one. text is the default property for both of these. The compiler cannot always do this - in some
    cases it's ambiguous - but when there is no ambiguity, it compiles without complaining.

Anyway, at the end of the demo I deploy. This compiles the BASIC file down to a Java bytecode class, which is located and instantiated by the
JSF managed beans machinery at runtime. As a result, the application works and the JSF framework has no idea it's talking to BASIC code.

So that's the keynote. At some point, the technical sessions will be made available online, so you can get all the gory details from TS-3576. Last year's presentations are available here - as you can see, you get both the slides and the synchronized audio track. This year they asked us to reduce the resolution on our laptop, even though it was showing fine on the projector, because some recording equipment needed it, so if we're lucky, the demos will be included in this year's multimedia version. As I mentioned the other day, for now you can see some demo screenshots and descriptions in Herbert's blog.

Friday, May 19, 2006

Java Posse live session

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

We had a Java Posse live session at JavaOne. The room was packed and it was a blast. And I think the audience liked it too. We recorded it, so you can check out the audio here.

I just noticed that in O'Reilly's OnJava writeup, "JavaOne Day One" by Robert Cooper, he not only mentioned the event, but called it the highlight of the day! Thanks! He has a couple of pictures too. Check out the ridiculous hats! A really weird thing happened later that night at the pub. Somebody, nobody knew who, ran into the pub, grabbed the hat right off my hat and ran off! We never knew who took it. Hey, that was one quarter of the Java Posse's marketing budget :)

We've recorded many other interviews too, that will be posted gradually. Not only because it takes time to edit all that audio, but also such that we can be a bit lazy during the next few weeks, as we recover from JavaOne and all the preparations for it!

Project Semplice (Visual Basic for the Java platform) launched

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

As promised,
I was planning on writing a full report from our TS-3576 talk at JavaOne, but my teammate Herbert has already done a great and thorough job. Read his entry for all the juicy details! Here's a teaser screenshot:

Tuesday, May 16, 2006

JavaOne So Far

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

JavaOne is well underway. It's been great so far. We had our demo in the technical keynote this afternoon. It was short, but everything worked smoothly. I'll have a lot more to say about it later. Perhaps I'll throw in some screenshots and a narrative, similar to the keynote demo I did
last year.

So by now it's no longer a secret: I don't work on Creator anymore, and haven't for about nine months. I'm on a new project, Project Semplice (pronounce that in Italian, by the way). This does not mean that Creator is in any way losing momentum - there are two new developers working on the page designer for example. But having been on Creator through two full releases, it was time to try something new. And the new project works on adding a new language to the VM. That seems like a major theme of JavaOne this year. We can accomodate multiple languages on the platform - both in interpreted mode ala JSR 223 Scripting Engines as supported in Mustang, as well as languages that compile down to class files just like .java files. Saying that I work on a "new language" may be a bit misleading: we're trying to target a language inspired by Visual Basic. There's no suitable marketing name for it yet, so in our slides, we're just referring to it as BASIC. Or, for a real mouthful, Project Semplice BASIC. We're going to have a technical session on Thursday at 9:45 (note the time! It changed from its original 1:30 timeslot). We'll have a lot more demos and in-depth coverage of aspects of the language.

Tonight we're having a session for the Java Posse. We're going to record a live session. The session is packed (according to pre-registration numbers). We've been promising on the podcast that we'll have a keg. That was the plan. Two-three years ago, when we launched Creator, we had a "Meet the Creator Team" session, and we brought a keg. We thought we'd just do that for our Posse BOF as well. But we discovered today that the BOF is going to be held in a nearby hotel, not Moscone center, and they have a no-keg policy!! They -do- allow us to have beer served - but we'd have to pay for each and every bottle of beer served, at $7 per bottle! With a couple hundred people attending that's going to be quite expensive. After all, this is just a hobby project for the four of us, un-affiliated with our jobs. We have no sponsors (which is why the podcasts have no commercials in them), so especially with some recent recording gear expenses, it's just not within our budget. So a big apology to those of you who are planning to attend the session purely based on the free beer we had promised :(

NetBeans Day yesterday went well. I was particularly impressed with some of the new demos I hadn't seen before -- like the new Subversion integration. I can't wait to get away from CVS! I also really liked the XML tools support. The platform development and the Java EE 5 demos were impressive as well, but I had seen that before and new stuff always has more appeal. I spent the evening with people I met randomly at the end of the event along with the Java Posse. We recorded several great interviews that we will publish as soon as we get time to edit them. One of the interviews were with findbugs founder Bill Pugh, and author and consultant Brian Goetz. It was a great interview covering subjects I think all developers find interesting -- bugs, tricky bugs, detecting bugs, concurrency issues, and so on. We also interviewed Steve Northover, the SWT lead at IBM. We've also got plans to interview the Swing guys this week (who did a fantastic keynote demo!), so that should be a nice pair of compare and contrast episodes.

I'm having a blast. So much fun that I can tell I'm losing my voice. I did this at the Java Polis conference back in December too. Hopefully I'll still have some speech left for the Posse recording session tonight.

Anyway, the big thing I want to get across with this blog entry is that you should NOT miss our technical session on Thursday, TS-3576, covering the new project - BASIC for the java platform! The other two speakers are the other two guys on the Semplice team: Herbert Czymontek and John "Get a blog" Kline .

Friday, May 12, 2006

Phew!! Ready for JavaOne.

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

I've been silent lately, but for a good reason. It's been a crazy month. It's like being back in college again, complete with coding all-nighters. But as of late last night, everything is working beautifully - so I can catch up on some sleep this weekend before the fun begins!

The other guys on the Java Posse went out to Las Vegas last week and had a lot of fun. They even recorded some live podcasts from the TopCoder open. I unfortunately had to miss it. The trip was scheduled a while back, but I declined since I knew from experience the month leading up to JavaOne is always hectic for me. And I was more right than I wish I had been!

Be sure you don't miss our technical session - TS-3576. It has been moved. It is no longer at 1:30, it's at 9:45am in the morning on Thursday, so be sure to check the updated schedule. I can't give any more details about the talk yet, but hopefully you'll see more in a brief demo in one of the keynotes! I have two other "gigs" too: The JavaPosse BOF, which should be a lot of fun, on Tuesday night. And the JSR 273 BOF, on Wednesday night. With a technical session on Thursday and a possible keynote on Tuesday, and hopefully lots of podcast recording sessions and other social gatherings, this is going to be a blast.

But first, sleep!! Zzzzzzz

P.S. I have 1200 unread e-mail messages in my inbox. If some of them are from you, I apologize.