Tuesday, October 30, 2007

Scapegoating for Java crisis on Mac OS X

So, pretty much all Java developers working on Mac OS X are filling up the blogosphere (sorry for using the cheesy term) screaming how Apple left them behind not releasing Java 6 for Leopard. This article (via DF) summarizes the overall sentiment (and somewhat hysterical atmosphere). Apple's own java-dev list is another place where people are raising concerned voices.

It's understandable where this outcry comes from. Go to any major Java conference. The Mac laptops are totally over-represented in the audience.

I could well be among them. I'm guilty of amplifying the "Macs are everywhere" effect at conferences myself with my MacBook Pro. I too am a Java developer working on Mac OS X.

I just see a different perspective to things. First off, it always struck me as actually very unnatural that Sun ships Java for Windows, Linux, and Solaris, but does not ship it for Mac OS X. I don't feel let down by Apple here.

I feel let down by Sun.

Sun already publishes a JDK and JRE for three different OS platforms. How hard would it be for them to publish it for Mac OS X as well?

It appeared to me that Sun just recently started natively supporting OpenOffice on Mac OS X. The concept is not completely alien to them, then.

Looking realistically, what is the supposed rationale behind having Apple ship Java for Mac OS X? My educated guess is that the reasons are twofold:

One, OS X was originally so small marketshare-wise that Sun simply couldn't be bothered. They probably had they doubts about the success of the OS. So Apple undertook porting Java to increase the potential software base of the OS and its overall utility. Remember, Mac OS X at the time was still quite young. Hopefully this has changed by now, especially seeing how lots of Sun employees also use Mac OS X. So there's me hoping that in 2007, Sun could actually be bothered.

Two, Apple provided some Apple-specific functionality, like Swing that looks almost like native Mac UI, plus a Cocoa bridge (which is not updated to keep up with Cocoa improvements for quite some time, and is declared by Apple to not be updated ever again).

Don't get me wrong, but the vast majority of Java developers on Mac doesn't give a shit about either Swing or Java-Cocoa bridge, or anything else there might be. Java isn't doing particularly well on desktops; strong Java market is on the server side. As a consequence, vast majority of Java developers don't deploy their software on Mac OS X. They deploy it on enterprise irons that typically run Linux or Solaris. I'm in this crowd.

Let me repeat: I don't give a flying shit about Mac OS X specific Java functionality. If I wanted to write a Mac desktop app, I'd use Objective-C. If I wanted to write a cross-platform desktop app (ha!), I'd probably first talk myself out of it, and if I really couldn't, I'd go for SWT. I'd be more than happy with Java on Mac that allows me to do my command line and server side stuff. I wouldn't care that it has us an ugly looking UI with Swing (as it does on all other platforms, anyway).

And I firmly believe it is Sun's job to give us one, not Apple's.

If you're following what Apple is doing with its developer strategy, it'd be clear to you Apple doesn't have any interest in Java on Mac OS X, and I can't actually blame them for that. Apple is slowly abandoning lots of technologies. It is slowly abandoning Carbon (Carbon will have no 64 bit support, ever). Apple is slowly abandoning non-Cocoa QuickTime bindings (they too will have no 64 bit support). Apple's developer strategy is unification: everything is Cocoa and Objective-C.

In an interesting twist that seemingly (but only seemingly) contradicts what I wrote above about unification, Apple ships Ruby and Python bundled with the OS. However, please observe that both of these are (a) open source and (b) support compiling on Mac OS X in their mainline source code. That is to say, the original developers of the code provide OS X support by sprinkling required #ifdef blocks around the code. Apple just needs to take it and bundle it, without further tailoring. That's what they do. To Apple, Python and Ruby are just Darwin-level tools. And even if they didn't bundle it, it'd be trivial for anyone to compile them from the source and install. Fink and DarwinPorts can give you newer versions of either if you need them. Neither (a) nor (b) can be said of Java. OpenJDK is not Java. Not yet. Sun is definitely heading in the right direction with open sourcing Java, but they started too late to avoid this particular crisis.

Relying on Apple to deliver the Mac part of the WORA promise was a mistake, one that could be easily seen by anyone for years, as Mac users were getting their JDK updates with six months or longer delays compared to platforms serviced by Sun. Sun would've had plenty of time to act upon this mistake.

Again, is it Apple's fault that we don't have an industry-grade open-source Java implementation that supports Mac OS X in its mainline source code? I don't think so. If you want to be angry at someone, or better yet, you want to petition someone about the situation, please direct your energies at Sun.

UPDATES:

  • OS X Java Definitive Timeline shows the problem of letting Apple - a party for who Java is low-priority business - take care of delivering it on its platform: worst lag in release schedule was 21 months for Java 1.4 to show up in Mac OS X.

  • Also there, Comic: Apple’s Pathetic Java Support? Oh Really? saying
    Dear Steve,

    Writing your own JDK is really hard. Maybe you should follow Microsoft’s lead and let Sun do the dirty work?
    Well, yeah, if only Sun wanted to do it.

  • In Shipping means prioritizing Gruber also reinforces my point:
    Perl, Python, and Ruby pretty much compile out of the box on Mac OS X. Apple doesn’t have to do much at all — at least relative to Java — to include them on Mac OS X. Why? Because that’s how these tools are designed and engineered — they’re made to “just build” on any Unix-like OS. It’s not Apple’s responsibility that Java isn’t like that — it’s Sun’s.
    He's also quite confident we'll see Java 6 in Mac OS shipped soon, if the timeline above is any indication.


Fastest Vista laptop is MacBook Pro

According to PC World's "The Most Notable Notebooks of 2007" article, of all laptops they tested this year, the one that runs Windows Vista fastest is - MacBook Pro! They conclude with:

... MacBook's score is far more impressive simply because Apple couldn't care less whether you run Windows.

(Via Daring Fireball)

Thursday, October 18, 2007

Linux preinstalled on Acer laptops - a scam?

Here's a bit of a firsthand bitter experience with laptops and Linux from last week. (It's also another hard reminder why I run Apple computer gear exclusively for myself for two years now.)

My wife's aunt wanted to buy herself a computer. She wanted the "usual" functionality, y'know, browse the web, e-mail, listen to music, watch movies, online chat. It also must have a hungarian UI. I suggested she gets a desktop computer, but she insisted on a laptop. Oh well, it's her money.

Her budget was half of what you'd need for a MacBook. Not wanting to enrich Microsoft's Windows division, I suggested we get a laptop that comes with Linux preinstalled. I had some successes installing Ubuntu Linux on some machines lately (one of them an oldie IBM ThinkPad where Ubuntu even recognized the PCMCIA wireless card without a hitch). Also, seeing how she lives 100 km from here, I didn't feel like doing tech support on it often, which is something I believe I would end up doing with Windows (if my wife's machine is any indication).

My argument was that for the same money, we'll get a stronger machine, since the manufacturer didn't have to scale back the hardware budget to accomodate a Windows license.

We ended up buying an Acer Aspire 5315 that's distributed locally in a Linux configuration for 120000 HUF (660 USD).

Now, the first thing is that it comes with a Linux distribution named "Linpus Linux". There's no install CD so I can't reinstall it if anything goes wrong. Also, I can't install any graphical interface. That's right. In 2007, a machine equipped with a 1280x800 screen, gigabit ethernet, wifi, DVD burner, and bluetooth comes with a preinstalled OS that dumps you to a shell prompt upon boot. No graphical environment whatsoever is preinstalled. I've tinkered with it a bit, and noticed it doesn't actually bring up the wireless network interface. We'll see later why.

Ok, so let's install a proper Linux on it. I started with Freespire - it's an Ubuntu derivative, but comes with non-free media codecs. Just what I need, so auntie doesn't nag me later that she can't play back MP3 and WMA files. It went up without a hitch, but I hit exactly three problems with it:


  • Sound drivers claim to work, but no sound comes out.

  • The Atheros wifi chipset is too new, so it's not yet supported by pci_ath

  • An attempt to install hungarian language ends up with error message saying qt_language_selector is not found


Trust me, I've spent fair ammount of time browsing all sorts of support forums to solve these, but had to throw in the towel in the end.

Next, I tried a mainline Ubuntu distro (Feisty Fawn). This ended rather quickly - I got dumped into a BusyBox command prompt by the installer. Turns out FF doesn't recognize the chipset, and thus can't detect the hard disk drive properly, and as a last ditch measure gives me a command prompt. Geez...

At this point, I decided to give Windows XP a try. I had a copy of WXP SP 2 at hand, so I tried installing that if only to see whether the sound might be defective in hardware (if WXP drives the sound chip, then it's apparently not). To my utter surprise and disbelief, WXP installer also failed to recognize there is a HDD in the machine. Ouch. Friends are telling me that I'd need to provide the installer with SATA drivers externally. Yeah. Provided I can find them. And then there's the minor issue that Windows XP installer only accepts external drivers through a - you guessed it - floppy drive! Yes, there are USB FDDs. I've also heard some newer BIOSes can present a USB pen drive as a floppy. Still, what would've it taken to write the damn thing so that it can accept external drivers from a CD?

Back to Linux - there's another Ubuntu derivative named Kiwi. I chose it because, similar to Freespire, it comes with nonfree codecs preinstalled, and can be installed in Hungarian language by default, so Freespire's language selector problems at least won't trouble me. It was also based on next Ubuntu release - Gutsy Gibbon.

Well, what can I say. It did boot and install, but the sound still didn't work, and I still couldn't get wifi to work. Yes, I did try ndiswrapper with Windows drivers, but even after I blacklisted pci_ath and rebooted, some part of the OS still pulled pci_ath, which took precedence, but was unable to drive the new chipset.

So, I had to admit defeat. I wasted sunday evening, monday evening, and part of tuesday evening on this. My time is worth more to me than this.

So I phoned an IT shop in the city and asked them for a quotation on Windows Vista Home Basic. (Seeing how XP doesn't install, how Acer itself suggests Vista, and how the driver CD only contains Vista drivers.) With Vista, sound works (not a hardware problem then), wireless works. All hardware works.

But here's my question: why does a company sell a computer with Linux preinstalled if there's no Linux distribution currently on planet that can, installed out of the box, correctly drive all of its hardware? What can be said of such a marketing practice? In case of Acer Aspire 5315, at least the wireless and audio didn't work (and I haven't tested either the Bluetooth or the DVD burner, so I can't say they either work or don't).

If they aren't aware of the hardware support limitations, shame on them for being unprofessional. If they are aware of it, shame on them for enticing us on purchasing the machine by representing that it has an OS installed appropriate for it. Duh.

Vista install is running as I'm writing this. I'm cheering myself up thinking of how next time I'll be installing an OS it'll be Leopard on my two Macs.

Thursday, October 04, 2007

Language trendspotting at JAOO

Surveying the talks this year at JAOO, it is hard not to notice that nobody is getting too excited about either Java or C# anymore.

Ruby of course had a full track to itself on monday, and a track named "Enterprise Application Frameworks" on Wednesday was also pretty much Ruby/Rails dominated.

On the other hand, other languages were in the limelight too. We had a great introductory presentation on Erlang by Joe Armstrong, one of the principal inventors of the language. Erlang is the old-new contestant for the title of "right answer to concurrency challenge", and it really looks like it solves the challenge correctly for a fair ammount of use cases I can think of. Basically, whenever you can afford a share-nothing message passing architecture.

We also had a presentation of Scala. Scala must be my favorite language for about two years now even if I didn't write anything in it yet :-). You just got to love all the modern amenities in it that are missing from Java: type inference, very good syntax for map and list literals, closures, a really polished generics implementation (it allows contravariance, by golly!), plus assorted functional programming goodies, not the least of them being Haskell-style datatypes. Oh, and it is static and compiles to a plain Java .class, creating a very low (virtually nonexistent) entry barrier for gradual introduction into your existing Java code.

Oh, and people are talking about JavaScript as well :-)

Glenn Vanderburg gave a talk titled "The Overlooked Power of JavaScript", which was exactly what it said. The language had quite an injustice done to it because of its unfortunate name choosing -- as we know and as Glenn pointed it out correctly, it is not related to Java at all, its ancestry comes from Scheme and NewtonScript (useless trivia: I actually wrote a commercial application for Newton in NewtonScript back in 1996).

JavaScript is an incredibly powerful language if you can get rid of the preconception that you need to handle it as you'd handle Java. Once you get past that and actually understand how things work in it, you can develop some mightily beautiful code in JavaScript, as the extreme dynamism of the language allows you refactorings simply not possible in more constrained languages. You can end up with some very tight internal DSLs. And I'm not talking only about code to run in a web browser -- I'm talking about applications running on desktop or on a web server.

To demonstrate the power of the language even further, there was a presentation of Flapjax on JAOO this year. Flapjax feels like a language, but in reality it is "just" a JavaScript library, but one that allows you to program your browser-run client applications in an event driven manner, plus supporting reactive evaluation (think self-recalculating cells in Excel) when events change values. "Event" in Flapjax can be almost anything -- a tick of a timer, a click of a mouse, asynchronous completion of a HTTP request, and so on. You can concisely express your program in terms of reactions to such events, and also always preserve consistent internal state of all variables thanks to its self-recalculations, all with fairly intuitive syntax. That's quite a something from "just a library" in JavaScript :-) Flapjax was covered on LtU as well about a year ago.

So, all-in-all, language diversity is again in fashion. Developers seem to finally recognize that a language is just a part of their toolbox, and that you need to choose the right tool for the right job. Of course, I know that the same developers usually need to also convince their managers about this point of view, but fortunately this seems like it'll become easier with language diversity now being an accepted trend at respected conferences.

Friday, September 21, 2007

JAOO

Just a heads up that, following what seems to become an established previous tradition, I'll be attending the JAOO conference this year as well. See ya in Aarhus next week!

Thursday, September 20, 2007

Laugh-Out-Loud Cats

I'll admit that I was mildly annoyed by the whole LOLCats meme. I don't say I didn't get it; I did, I just felt it overdone after a while and couldn't be bothered to pay attention to yet another photo with funnilz missspelt all-caps would-be-jokes superimposed on them.


Until Ape Lad created something wonderful out of it.


Ape Lad, or Adam Koford is an illustrator maybe best known for his graphical interpretation of various hobos from John Hodgman's book "Areas of My Expertise", but I think that soon he'll be referred to primarily as "the guy who created Laugh-Out-Loud Cats".


So, what is it he did with the LOLCats phenomenon? He created a 1920-style cartoon featuring two vagabond cats, as he himself says "one Meowlin Q. Kitteh (a sort of cat hobo-raconteur) and his young hapless kitten friend, Pip". These cartoons are produced traditionally, pen-and-paper, and have an incredibly authentically-feeling atmosphere of the '20s, plus a fantastic chemistry resulting from mixture of innocence, mischief, and cuteness overload in the characters. Just click on the image to the left for the gallery -- it's all available for free viewing on his Flickr account, and I'm looking at its RSS feed with most anticipation every morning for updates (and I'm seldom disappointed, because the guy is really prolific)!


Of course, you might as well check out his other fine works, like his graphical interpretations of various HTTP error codes (to the left, you can see "415 Unsupported Media Type").

Tuesday, September 18, 2007

Liquids on planes in Europe will be allowed again!

Frequent air travelers rejoice!


Apparently, Norwegian Ministry of Transportation asked the European Parliament to move to lift the liquid ban on airplanes. They say it is "annoying for the travellers", and a "large cost for society".


And apparently, the European Parliament agrees!


Sorry if I'm sounding euphoric about this, but this mindless fake security measure did cause me lot of headache in the past. Sometimes literally - there are those situations when I need to catch a transfer and the itinerary is so tight I barely can run from one gate to the other and I don't have time to grab an (overpriced) bottle of water at the airport, so I get a headache of dehydration by the end of the trip. small glasses of water and orange juice served at the airplane are not the same thing. Actually, lately I switched to carrying apples with me for liquid replenishment.


In the meantime, I need to find an (a) aerosol deodorant not exceeding 100ml and (b) shaving foam container not exceeding 100ml for my next week's trip to JAOO in Aarhus (I'm flying with hand baggage only). I figure I can just use the hotel bathroom soap in dire need instead of the shaving foam though. Oh man, can't wait for this madness to end.

Sunday, September 16, 2007

Closures in Java NOW!

I remember Neal Gafter's talk about his idea of how to implement closures in Java that he gave at TSSJS in Las Vegas this March, and I have to say, if we had this feature today, it'd be none too soon.


Lack of closures does give Java a reeeally bad feel in 2007. It makes it very backwards looking in terms of modern programming language amenities, compared to languages that already have them.


Here, let me show you an example.


As we all know, in Java, objects can't control their own locking - they can't customize their behavior when used in a synchronized block. Now, that's one entertaining problem in its own right, and would deserve its very own discussion, as basically, it makes correctness of synchronization dependent on implementation. But that's not the point of this post. The point of this post is how one might try to work around this and similar lackings, and how one will inevitably fail...


Okay, the example: let's suppose I have a class A. I sometimes need to lock instances of it. This is a no-brainer in Java and usually has the form of

synchronized(a) {
... do something...
}

Let's suppose I also have a subclass B of A. Instances of B have a reference to another object of some class S, and various instances of B share some of their state through shared instances of S for some reason:
public class B extends A {
private final S shared;
...
}

Since the S instance is actually shared among several B instances, the correct locking semantics for B would be to always synchronize on the "shared" field of a B, when client code synchronizes on an instance of B. Unfortunately, there's no way in Java to declare to do a synchronized(b.shared) within every synchronized(b).


What's the next best thing I can do - provided I want to encapsulate the behavior and want to avoid some manual monster code1 at every synchronization site? A smart aleck like me would add a method to A:

public void runLocked(Runnable r) {
synchronized(this) {
r.run();
}
}

Then, I can override it in B:
@Override
public void runLocked(Runnable r) {
synchronized(this) {
synchronized(shared) {
r.run();
}
}
}

Finally, I can replace all occurrences of a synchronized(a) block with:
a.runLocked(new Runnable() {
public void run() {
... do something...
}
});

Sounds okay? Well, it isn't. Aside from the very obvious "too much visual clutter" problem, there are further problems with this:

  • What if "do something" throws a checked exception? (Answer: more monster code2)

  • What if "do something" modifies a local variable? (Answer: yet more monster code3)

  • What if "do something" contains a return, continue, or break statement? (Answer: you are seriously out of luck, but some really horrid monster code might help you out. It is so ugly though that it does question the ROI of the whole approach. No, I won't give an example.)


So, what happens is that you eliminate ugliness in one place, only to have it resurface because of these other problems in another place. It is not really possible to arrive at a win-win situation with current language constructs. (Alternatively, I'm not smart enough to figure it out. Either way, pity). Needless to say, if we had real closures in Java instead of the very weak imitation attempt in form of java.lang.Runnable, none of these would be a problem.


1 the monster code in question would look something like:
synchronized(a) {
if(a instanceof B) {
synchronized(((B)a).getShared()) {
... do something ...
}
} else {
... repeat do something ...
}
}


2 the monster code for working around checked exceptions would be:

try {
a.runLocked(new Runnable() {
public void run() {
try {
... do something ...
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new UndeclareThrowableException(e);
}
}
});
} catch(UndeclaredThrowableException e) {
Throwable t = e.getCause();
if(t instanceof Exception) throw (Exception)e;
if(t instanceof Error) throw (Error)e;
throw e;
}

And it can get even more fun if you're trying to only get a specific type of a checked exception (say, IOException) and not a generic Exception across the scope.


3 the monster code for working out local variable modifications would be:

final Object[] embeddedLocalVar = new Object[1];
embeddedLocalVar[0] = realLocalVar;
a.runLocked(new Runnable() {
public void run() {
... do something ...
embeddedLocalVar[0] = newValue;
}
});
realLocalVar = embeddedLocalVar[0];

Pure beauty, innit?

Friday, September 07, 2007

"How can a spinozan cast a dualism spell?"

If you enjoy reading works of Jostein Gaarder (come on, you must've read at least "Sophie's World", haven't you?), and if you likewise enjoy reading any or all of Greg Egan, Charles Stross, or Neil Gaiman, then you'd adore a hilarious webcomic about (in no particular order): philosophy (if you can actually get the joke in the post title), quantum physics, psychology (with regular appearances of "Tiny Carl Jung"!), all with a big dose of surrealism.

That's exactly what Dresden Codak is.

If I may recommend, start reading from this one, as it and the next few ones are extraordinarily brilliant (contrasted with the rest, which are just, well, ordinarily brilliant). Then revisit the older ones after you reached the end.

My only woe is that there aren't too many of them yet, and it's not updated too frequently. But hey, quality work needs time!

Sunday, August 19, 2007

The World's Toughest Programmer: "How I became a programmer"

I recently discovered the blog of The World's Toughest Programmer a.k.a Mike Lee, and I can't help already loving him. He hasn't written a lot in his blog for now, but what he did was very thought provoking so far. His newest writing "How I became a programmer" is a must read. Tagline:

I was born a programmer. The rest is just implementation detail.

:-)

Wednesday, August 01, 2007

Mac Mini colocation

www.macminicolo.net (Seen it referred from here, being mentioned for their superb consumer care).

As tongue-in-cheek as this sounds at first, yep, these guys do actually provide managed hosting of Mac Minis (you can send one to them, buy one from them at Apple's prices, or even rent it). The idea is a bit weird, but makes sense if you need a dedicated server on the net, you want Mac OS X on it because you are familiar with it, and you don't want to shell out for an XServe. Oh, and yes, you can run Mac OS X Server on Minis if you really need it.

Monday, July 30, 2007

Fun and woes with VNC

So, we are at a holiday in Palma de Mallorca momentarily. Unfortunately, we could only bring one of our Macs here - my MacBook Pro ' and had to left wifes 20" iMac at home for obvious reasons (it is not too portable, although I did lug it to UK and back once when it was my primary machine). Our hosts however have an oldie G4 eMac. Since both of us need a machine frequently, I tried to remedy the problem using VNC - Vine VNC server on the MacBook, Chicken of the VNC client on the eMac, so one of us can work logged on in their account from eMac while the other person sits at the MacBook proper.

It mostly works fine. But then, there are annoyances.

First annoyance - the system works on two desktops, except when the user of the remote desktop wants to use VMWare. In that case, using fast user switching hangs the remote VNC sesion. No big deal - we will just have the one of use not using it work remotely. (Surprisingly, that is me - Kriszti actually has some Windows-only software she runs).

Second, much bigger annoyance - keyboard incompatibility. I tried both an Apple keyboard plugged into the eMac as well as a Windows keyboard only to realize there's a deeper reason why I can't punch in many characters (curly brackets included - kills any attempt at coding). The reason is that the MacBook still maps keycodes accordingly to its builtin keyboard. I learned this after many futile attempts to press certain keys and evoke any kind of response, I finally brougt up the Keyboard Viewer, and it pretty much displayed the MacBook Pro uiltin keyboard layout... If I try to press keys on a full size keyboard that aren't present on the laptop's built in keyboard, theyre simply ignored. Quite a lot other keys aren't in the expected place. I guess it's partially to blame that all external keyboards in the house are Spanish and the laptop's is Hungarian... But even switching the keyboard layout in the remote machine to "Spanish ISO" doesn't help anything... I tried to plug in one of the USB keyboards in the laptop, to solve the keyboard mapping mismatch issue, as the OS would then try to map according to that. Didn't work.

So, it's far from being a perfect remote GUI solution, unfortunately. It's okay for casual checking of e-mail (mailbox being on the other machine) but really not much else. Sigh.

Thursday, July 26, 2007

First cut at the JVM dynamic languages metaobject protocol

You might remember I was musing about coming up with a framework library for extensible metaobject protocol to be used for dynamic language runtimes on JVM a while ago. The main thing it would give all those language runtimes is interoperability: you could write your program in mixture of JavaScript, Ruby, Python, etc. - using the best language for a particular subtask (or better yet, cherry-picking existing components regardless of their language), and still pass objects created from code in one language to code in another language, and have them all see those objects as being no different than their native objects.

Well, since talk is cheap compared to working code (and also because if I can express a concept as clearly as to have a computer execute it then I can probably make people understand it better too), I have a first version of the implementation, not yet fully complete, and first and foremost for the purposes of soliciting feedback from the community, available now.

(For the record, I blew several days of my vacation in Palma de Mallorca on getting this code into publishable state and suffered numerous scorns from my wife so far for doing so. Goes with the territory, both ways... ;-) )

The initial announcement was made on the JVM Languages group, go read the details (including where to find the code and documentation) there if you're interested.

Thursday, July 05, 2007

Brief report from a Neil Gaiman signing event

I'm officially crazy in lots of ways. A particular kind of crazy I am is the one I demonstrated yesterday, when I went to a Neil Gaiman signing event in Budapest.

What's crazy about it? Well, probably nothing if you actually live in Budapest. I don't, so for one thing, it's crazy driving 2 hours to Budapest in pouring rain with near zero visibility. Then it's mildly crazy standing in a queue for two hours (part of it in rain outside the bookshop that was the signing venue. No umbrella). The final crazy (although strictly necessary after the first one) is driving home after the event in pouring rain with near zero visibility after dark. Of course, I'm really crazy because I still feel that spending six hours and about forty litres of fuel is a good investment in return for getting seven of my Gaiman books dedicated, and am totally happy about it.

Y'know, in my environment, barely anyone knows who this guy is (now that I think of it, this says something about people surrounding me. I also cannot lend my copies of his books to many folks around here to spread the culture 'cause they're all in English - I don't need no Hungarian translations, most of my friends however can't read the English originals). So I was fairly surprised when I arrived at the bookstore to find a queue extending into the street. The event itself wasn't even too formal - Neil announced it on his blog few days earlier citing as the reason lots of e-mails from local fans (yours truly included) who asked if he could please arrange a signing during his two-week stay in Hungary, seeing how he's otherwise not really often present in this corner of the world.

As for the venue itself, it was the Sárkánytűz ("Dragon Fire"), a bookstore specializing in fantasy books, card games, etc. I really couldn't help feeling that the signing was organized in a wrong location. I look with disdain at most of the contemporary fantasy literature. Most of it is just bad pulp fiction, its authors unable to free themselves from the cliché dominated by elves, trolls, halflings, dragons and knights. Ironically, a genre called "fantasy" really lacks authors that would have any real imagination. Neil Gaiman, on the other hand creates completely original stories, with completely original creatures, and the worlds he paints in his books intersect with our reality. Nothing could be further from the Tolkien-imitating cliché of elves and dragons permeating most of what the bookstore had to offer.

There's apparently a funny phenomenon associated with people queueing in the street in Budapest. Namely, it raises curiosity in strangers. While I was still standing in the part of the queue that extended out in the street, I was approached twice - once by a nicely dressed lady in her fifties, once by a guy resembling a hobo who tries to disguise it. They both inquired about the nature of the event, the wording of their questions implying they were hoping for some sort of a sale. When I told them it was a signing, the guy who looked like a hobo in disguise quickly lost interest. The lady asked who is signing, and when she didn't recognize the name, she asked (seeing how it's a fantasy bookstore) if it is "some sort of fantasy" to which I replied that it definitely isn't. "Then it is sci-fi, right?". This instantly reminded me of "we have both kinds of music" line. I replied patiently that no, it isn't sci-fi either. Then what it is? Well, how do you summarize Neil Gaiman in a single sentence? You don't. I tried to explain to her that she could think of him as maybe a modern day equivalent to Edgar Alan Poe (which I know you might disagree with, as it's both oversimplification and also plain incorrect, but that was the best I could come up with quickly at the spot :-) ) Anyway, she did leave after this...

So, after two hours of queueing I finally got in front of the man himself, got to shake the hand that wrote all those stories and look into the eyes behind them all those same stories were born. Yes, why, I was impressed, even though Neil is really a very friendly and approachable guy (well, approachable through standing in a long queue, but that's barely his fault. I mean, it's really my fault for not reading more obscure authors). Driving up on the highway I had plenty of time to imagine all kinds of witty dialogue I might get into with him, but the cruel reality was that there were still lots of fans waiting for their turn, so it would've been rude to hold them up for inappropriately long time, so we only did a bit of a politeness chat, and I handed over all the seven books I brought for dedication. It'd really be foolish to expect anything more from a signing event, really. I got a drawing of a cracked heart in my copy of Fragile Things - very appropriate. Also, the original printed dedication for Anansi Boys is actually made for easy personalization, which he totally exploited. I can almost see how Neil came up with it after signing his books for years, and felt very smart about it when he wrote it. (If you don't know what I'm talking about, don't worry, just buy a copy of Anansi Boys and read the dedication. Of course, you can also read the rest of the book if you're so inclined, but that won't help you in better understanding what I just said. But it might be worth your time for unrelated reasons, though.)

I also asked whether he has (or at least has a promise to get) a book of Hungarian folklore tales, to which he replied that he actually got one last week and is halfway through it already. If he didn't, I'd have offered to send him one, which was an idea I got while reading The Monarch of the Glen novella from Fragile Things, seeing how it incorporated a motive from Norwegian folklore (namely, a huldra), and Hungarian folk tales definitely have their share of marvels waiting to be incorporated into contemporary literature (I certainly know, I read lots of those to my kids). Anyway, getting Neil to read some of those tales is already been taken care of, hooray. We'll be waiting for the results :-)

A very nice touch at the signing was Neil's daughter Maddy, who was handing out cookies to people standing in the line and later also offering sandwiches at the signing desk. I really needed a bit of refreshments before hitting the road home, so I was really grateful for those as well. I asked Maddy when will she give back her Dad's blog to him, and she said it was her last day as his guest blogger, but she lamented that she can not write the entry because she's here at the signing. I remarked that she could use an exotic technique known as "pen and paper" and later type it up in front of a computer; I have no idea if she took the suggestion, however her goodbye entry was up at 10:01 PM, which I don't actually understand as I can't imagine the signing was over by then and even less that they could reach their hotel room by then - I left at about 9:15, and the queue of waiting fans still extended through the bookstore to the door (nobody waiting on the street anymore though).

Barcelona

So, Kriszti and me have been to Barcelona last week. Nominally, I went to speak at the TSSJS Europe, realistically I attended the conference just long enough to deliver my talk. That's what you get for taking your wife with you, who insists you spend the time going around the city and seeing places, instead of attending, say, Gregor Hohpe's talk about event driven programming (that one I really would've wanted to hear, but alas, I was stuck sightseeing Sagrada Familia instead; woe is me).

Barcelona must be one of the most joyful places I've ever been. The atmosphere of the whole city is amazing, the buildings, the people, everything is vibrant and alive. Architecturally, they have wide main streets with a very wide pedestrian area (usually with greens, benches, and fountains) in the middle, and lanes for cars surrounding it. Drivers are very mindful of the pedestrians and will wait for them to cross the street even when they (the cars) have the green light. Patiently.

Then there's Sagrada Familia. I don't think I've ever been as impressed by a cathedral as I was by it, especially since this is the first one that I can't view purely as a historical monument, main reason being it's still being built. You step into it, and it's full of construction workers. Cathedrals are always monuments to ages in which they were built, and this one is a monument to our age instead of some long gone one, making it even more easier to feel like it you have a personal connection to it. Y'know, like when you visit a cathedral and they tell you "... the XY cathedral has been built for 300 years..."; well, this one is still in its first 100 or so years :-)

Architecturally, it is also quite amazing, and departs from "traditional" cathedrals in quite a lot of places. Pillar structure is such that pillars branch at the top, giving the illusion of trees, further emphasized by the ceiling that also tries (quite successfully) to look like foliage.

Then there are various other Gaudi projects in the city: Casa_Milà, Parc Güell, and so on, all definitely worth several hours of one's time.

We also went to see an evening flamenco show with a dinner (courtesy Klaasjan) which turned out really great, both the flamenco performers and the dinner were terrific. And on the previous evening, we hung out at the hotel's "bierstube" (which is to say, a spanish attempt at emulating a german beer place). A funny moment was when the staff kicked out Kirk and Cliff because they attempted to come in with two boxes of externally acquired pizza. The attitude of the staff was especially rude considering we were otherwise on a table with few hundreds of euros on the tab anyway, so what does it matter if two pizzas are eaten without generating a profit for the venue? Anyway, the guys ended up eating their pizzas from their boxes on the street. Kriszti and myself joined in for a bite (no photos of this overly casual event, regretfully :-) ).

On saturday, wife and me also had the pleasure of meeting with Jon Revusky and his wife Nuria (they're long time Barcelona residents) for lunch. (We were treated to really copious amounts of really great tapas in Cervezeria Catalana.) Jon and me are collaborating on FreeMarker for about five, six, or even more years now, and this was the first time we actually met personally.

The only dark side of the trip was airline luggage handling. Needless to say, they (Lufthansa + Newco, their ground services provider in Barcelona) lost our luggage between our connecting flights. That in itself isn't that bad, but they didn't deliver it until the day of our flight back! So we went out to the airport on sunday, got our boarding passes (from a really helpful lady at the Lufthansa ticketing desk), then went through security into the transit area, found the baggage room, stood in the line at the Lost+Found office, finally got to the front of the queue, been taken to a back room with hundreds of suitcases, found our own, went out from baggage room, back to departures to drop off the suitcase for the trip home, then again through security into the transit area. Simple, huh?

When we arrived home to Budapest, we went to the Lufthansa office at the airport to file a claim for luggage delay. The ladies working there said they don't deal with it as they don't have sufficient capacity to handle all such claims (I can believe that. They certainly gave the impression they have no capacity for anything whatsoever) and they told us to contact their office in the city, for which they can only give us e-mail address and fax number. The lady at the desk then proceeded to jot down the e-mail address on a piece of paper: fly@lufthansa.de. I respectfully noted that it seems unlikely that this'd be the e-mail address of the city office in Budapest, but she was insistent that it indeed is. I was too tired to argue. I spoke to Kirk on the phone today, and he said Lufthansa office at the Budapest airport is the "most useless place on the planet". I tend to agree.

All in all, the Barcelona trip was great. Got to see a marvelous city, met some new folks and met again some already known ones, eaten lots of good local food, drank some sangria and local wine, did one talk, watched flamenco dancers, seen a great sunset by the sea. What more to expect? (Well, on-time baggage delivery, maybe.)

Thursday, May 31, 2007

ROTFL

OMG!!11 ITZ AWSUM!!

(No, the blog hasn't been hacked. Yes, click the link. See for yourself.)

IM OUTTA YR LOOP

Friday, May 18, 2007

No online Ant API?!

(Warning: disgruntled rant below.)

Ok, so I'm writing an Ant task. I'd need the Ant API. Google "Ant API". First link is http://ant.apache.org/manual/api/index.html. Yeah, sounds about right; click. To my surprise, instead of the familiar JavaDoc page, I get this:

Apache Ant API has not been generated

If you see this page online at ant.apache.org, it is not a bug, but on purpose. We do not provide an online version of the API docs, they are included with all our distributions.

Now, just how arrogant is that? "On purpose"? Just exactly what purpose is that? Are you guys really this much bandwidth starved?

Just for the record, the JavaDoc is not included in all distributions. Y'know dear Ant team, since the Apache license pretty much takes away the power from you to dictate what's in a distribution, some distributions won't come with JavaDoc.

Like that obscure one that ships with XCode for Mac OS X, installed in /Developer/Java/Ant directory. I guess no one uses that anyway, right? I mean, what Java developer would be as insane to use Mac OS X, let alone the development tools that ship with it, right? I'm probably the only such loser on the planet, I can't imagine anything else can explain why noone has noticed this yet and told you about it, so you removed that silly claim from the page where the API docs should have been, and replaced it with, well, with the API docs. Give me a break.

You could say how that's Apple's fault, and I'd agree with you. But that you aren't helping at all is ridiculous, with as little as to keep an online accessible API docs for one of your highest-profile Java projects. In 2007, what Java open source project aspiring to claims of professionalism would purposefully refrains from hosting its JavaDocs on its site? If for nothing else, then all other factors being equal, people want to use their computers with least effort. With a computer connected to the Internet, the easiest way to get to an API is punch "$projectName API" into the browser's built-in Google search box and then hit the first link. Compare this to trying to find the relevant index.html on one's hard drive. Yeah, we're that spoiled.

Anyway, the first site on Google's search results list that can afford the horrid bandwidth and storage burden of hosting the Ant API is http://www.jajakarta.org/ant/ant-1.6.1/docs/ja/manual/api/help-doc.html. Kudos to them, and shame on whoever is responsible for this lameness in the Apache Ant team.

Wednesday, May 16, 2007

XStream

Whenever I'm faced with a programming problem to solve, the logical first thing I do is to rummage around the 'Net, trying to find an open-source library (preferrably non-GPL, i.e CPL or BSD licensed) that already solves it. Because reinventing the wheel is costly, and most of the time the problems are such that I can't imagine to be the first to have came across them.

Few months ago, I had a requirements for passing objects between JVMs. "Doh, serialization", you'd say. Right. Except that the other people on the project felt it'd be very helpful from the diagnostics perspective if we could inspect the objects. So the logical idea - serialize using XML instead of Sun's binary serialization format. Turns out that the JavaBeans API actually provides support for something similar in the java.beans.XMLEncoder and XMLDecoder classes. It will serialize/deserialize JavaBeans using their public property getters and setters. But we really wanted something that operates on the ObjectInputStream/ObjectOutputStream idiom and serializes fields.

Eventually, I found the XStream project at CodeHaus.

The logical second thing I do when I found an open-source library is examine it. Unfortunately, lots of stuff floating out there isn't of particularly high quality, and branding also doesn't guarantee quality, be it "Apache" or "Codehaus" or anything else.

Now, after using XStream for quite a while now, I must say: well done! It delivers on its promises, the code is architecturally sound, and is insanely customizable. The generated XML is rather compact - i.e. if a value of the serialized field is exactly the same type as the declared type of the field, the type is not written out in the XML. Only if a subclass is used as the actual value. What's more, types can be aliased both on serialization and deserialization. This allowed us to ship objects from a GUI frontend JVM to a DB backend JVM, and have them being serialized/deserialized as different subclasses of a common abstract superclass hierarchy. In the GUI frontend, they were deserialized as classes with GUI operations, on the DB backend, they were deserialized as Hibernate enabled classes. Just brilliant.

I know you can do it with Sun's default serialization as well, but you must override resolveClass or replaceObject in the object input stream. Whereas with XStream, you could just configure the aliases in a factory once, and be done with it. Very elegant.

It is also possible to plug in custom serializers for certain types - i.e. we had to make sure Hibernate-specific collection classes were serialized as plain Java collection classes. It probably took me all of a 20 minutes to implement it, relying on documentation and the XStream (quite clear) source code.

Then there's a rather ingenious default mechanism for backreferencing objects. You can configure XStream to slap an "id" attribute on each element representing a serialized object, and when you need to reference it from a later written object, refer it by the ID. Anyone could come up with that, it's rather trivial. But XStream doesn't do that by default. Instead, by default it doesn't write any ID, but if a later written object needs to backreference an earlier written one, it'll use an XPath expression that selects the earlier object's element! (You even have a choice between absolute XPath or XPath relative to the referencing element.) Again, very elegant.

And to top it all, XStream is not for XML only any longer. Since the serializers are pluggable, they currently also have a JSON serializer, which sure can come in handy if you're AJAXing. (I'm not, so can't give an account of experience in this regard.)

All in all, I'm currently very happy with XStream; if you need to serialize/deserialize your Java objects to/from XML or JSON, I recommend you give it a try.

Tuesday, May 15, 2007

My current open-source TODOs

I'll admit that I feel a bit thin-spread lately regarding my open source activities. There's just too much stuff going on that I'd need to attend to one way or the other. Of course, this is all competing for whatever leftover bits of my time after paid work ("urgent/important"), family, an attempt to reinstantiate a regular workout habit (both "not urgent/important") and the also inevitable everyday interruptions ("urgent/not important"). Just to make it clear, OSS work is to me in the same "not urgent/important" quadrant where family and workout take place.

In no particular order my current OSS activity goals are:

  • Implement support for invoking Java vararg methods from FreeMarker (this actually goes off the list, as I completed it on the quiet sunday afternoon while kids were at a birthday party)
  • Implement support for JSP 2.0 SimpleTag interface in FreeMarker's JSP taglib runtime
  • Fix the JSP taglib lookup mechanism in FreeMarker's JSP taglib runtime
  • Make the overloaded method invocation + varargs into a reusable library so I can support vararg methods in Rhino and also have other open-source dynalang communities leverage it
  • Support vararg methods in Rhino
  • Cleanup the LiveConnect implementation in Rhino (primitive booleans not coerced automatically, and in general overloaded method resolution could be better, and it doesn't use JavaBeans bean info, and...)
  • Just generally try to attend to bug reports in Rhino
  • Attempt to refactor Rhino-in-Spring to reuse Spring WebFlow as much as possible, 'cause having two webflow implementations on the same base code would really help it emerge into a flexible foundation worth submitting as a "Java Web Flow" JSR
There you go - I actually feel a bit better having written down all of this. If you wonder why I haven't answered a Rhino question for a week or so, it might be because I was busy working on a FreeMarker issue, or vice versa. Or just there were no birthdays lately, so I didn't have a quiet sunday afternoon at my disposal for some immersive hacking. But rest assured, I'm going forward with all this stuff, just not exactly on "Internet time" speed :-)

Friday, May 11, 2007

Fish Tank

I'm an avid reader of about a dozen different webcomics. Today, I just discovered another one, and it's just incredible in its originality. It's the Fish Tank, about adventures of three fish living in an aquarium (and quite often venturing outside of it). What's original about it? Well, these fishes occasionally get rid of piranhas (on an occasional visit to Brazil) by deorbiting a communication satelite on top of them using a satelite telephone, or get rid of a cat using explosives. Or are (in the current storyline) kidnapped by, of all things, telepath moths. Rooms, houses, or city blocks sometimes get demolished, or Alaskan wild forests set to fire. In general, there's lots of "Mission impossible" action going on, with fish improvising all sorts of devices from stuff found in their tanks and household items (not necessarily plausibly, but that's really not the point of it; they actually have laptops too!). The drawing is loveably sketchy (but consistent), and the characters are incredibly well built, complete with their love/hate relationships and plenty of ingenious throwaway jokes and inspired dialogue. Totally love it.