Tuesday, April 08, 2008

Beans!

Amazing news in from Microsoft:
That's right, a P2P chat application with NO code written by the user at all. I was struck by two thoughts - (a) Is Microsoft just telling a big fib, and (b) is it a good thing that P2P apps can be written with no code? Having recently downloaded the NetBeans 6.1 Beta IDE to help with some Java GUI, I decided to test this out...so channeling the reviewing style of Jeremy Clarkson and simile generation of Zero Punctuation, welcome to my first ever IDE roadtest:

Can NetBeans create a code-less P2P app?
Armed with only NetBeans 6.1 Beta, a little plastic ball of mouse in my right hand I can start this java experiment ‐ while my left hand is free to go off and make itself some coffee, play golf with Donald Trump, or really do whatever it wants now that it's not required to write any code. I foresee it could soon become quite the socialite.

The first step is upgrading my old NetBeans 6.0 to the new 6.1 version. Unfortunately, 'upgrade' here is a euphemism for complete reinstall, or 105Mb download for the J2EE users. While this isn't a major problem, the long wait does put the new version under as much pressure to impress as a Rock band releasing their second album.

Anyhow, with the download over, install complete, it's time to start the coding drag-and-dropping for our chat program.

Step 1) Database
Needing somewhere to store our chat data, I decide to take the Schwarzenegger-Humvee approach and get out the big guns, creating a codeless database. Thankfully, this is pretty painless in NetBeans, it's all there under the "Services" tab. After starting the Apache Derby DB server, I can "Create Database...", then expanding the tree allows me to "Create Table..." to store my messages:
and with that, the table is created with as little effort as it takes to find a Starbucks in New York.

Step 2) GUI
Now, creating the actual app project goes something like:
File -> New Project -> Java Desktop Application -> rename to "P2P" and select "Database Application" -> Select the newly created database table -> Include the both columns -> Finish!
Step 2.5) Bling
I must admit, that was easy and quick - and so is a Concorde, but they're both kinda ugly at first, although this GUI isn't French. Thankfully, changing colours and rearranging forms is still a codeless, right-hand-only job, but as a programmer, I decided to bring the art to the code, and make something Piet Mondrian would be proud of:

Step 3) Running!
So, having reached this far only requiring the coding knowledge of the average Big Brother contestant (no Java, no SQL, and not really English required) it's time to test it out chatting to myself. It's the standard click-the-giant-green-triangle trick two bring up two versions of the app (both of which are happy to compile & run no problems). And Voila! - a functioning P2P java app, about as useable as credit-card-cutlery, but it involved writing no code at all.
The only thing that was missing was needing to manually refresh to see new messages - it'd be cool if you could drag a timer onto the form that you can set up to call an action every K milliseconds, however I still consider this mission successful! No picture here, see above for the running app.

Step 4) Line-of-Code metric
A few quick asides: programmers often get paid by lines-of-code. In this project, I wrote zero lines, but inside the project folder running: cat `find . -name "*.java"` wc --lines tells me this app is 804 lines long! That translates into an impresive 500 words-per-minute...
Actually, let's boost that a bit by generating the javadocs too. In NetBeans, that's as simple as Right-Click P2P -> Generate Javadoc and after some thought, it spits out a pretty website:
To find out how many lines of html are generated:cat `find . -name "*.html"` wc --lines gives 5720.
This little Worker Bee has generated 6524 LOC, which is more lines than even the Rolling Stones did in their peak.
267684 html and java characters in 30 minutes is a staggering 1750 wpm, time to brew some real java beans I think.

Step 5) Conclusion

So there we have it, a brief demonstration of the current state of code-free coding. I must admit, I'm more of a DIY coder who'd prefer setting up the butterfly effect to write my code, over having it fed to me one Java Bean at a time, but I'm also aware (and thankful) that not everyone feels the same way. With the learning curve for Java GUIs about as steep as petrol price rises before a long weekend, I guess it's kind nice to think that P2P applications can now be written with little programming experience. Which oddly reminds me of MSN messenger again...

Edit: font sizes fixed, apologies - hopefully blogger won't overwrite them again this time.