2009-02-25

Swing 2: Pissing in the Wind

As nerds, it's all too easy for us to focus on technical merits to the exclusion of all else. Sadly, here in the real world, technical merits aren't the be-all and end-all. Repugnant though it may sound to some ears, most things come down to economics.

Take Swing 2, for example. The "vision" is the somewhat ungrammatical "Leverage current Swing know-how to create modern version Swing". But that's not what they mean. What they mean is "use Java 5 language features to perturb the Swing API". Specifically, the current focus is on cleaning up Swing's admittedly old-fashioned API: using enumerations instead of integer constants, using generics, and adding "varargs support". (I'm not sure quite what's meant by the last one, but it doesn't matter for the purposes of this post.)

Sun – sensibly enough – is not interested in making these changes, so the "Swing 2" guys plan to fork.

Why wouldn't Sun be interested? Surely it's embarrassing that JList has a constructor that takes a Vector<?>, for example? Surely there's no doubt that an enum is a better way to specify an enumeration than a bunch of ints? Surely we should splash some varargs around, now we have them?

Danny Coward responded but appears to have been too polite to get the point across.

That's where I come in.

If you read Danny Coward's response, check out the bits in bold. That's what a sane man sounds like. He talks about making it "easier to develop with Swing" and making the "runtime deploy and perform better". As long as "perform" covers look and feel as well as space/time performance, I don't think anyone could disagree that those are the most important possible goals for Swing.

The other important goal would probably be "enable developers to build stuff they can't currently build", but that seems to be the one Sun always ignores. They're too busy catching up with functionality that was old hat even in the days of Windows 95. (An about box, say, or a font dialog, or an embeddable browser component, or any number of other fairly basic things we still don't have in Java in 2009.)

I've written and worked on numerous Swing applications now, and can honestly say that none of the ideas mentioned so far for the third-party "Swing 2" would have helped in any way...

Enums What would making BorderLayout.EAST and friends enum constants buy me? I'll grant you that the Font constructor can be troublesome (which is it; size then flags, or flags then size?) but Font.deriveFont is a perfectly adequate work-around for that. Plus Font doesn't count because it's part of AWT, not Swing.

Generics Translating to or from a legacy collection is the work of a single line. More importantly, using a collection directly as your model is hardly defensible as good practice, so this just isn't an issue that comes up. (If you really want to improve the Swing model situation, you probably want to be thinking more along the lines of something like Glazed Lists.)

Varargs I'm baffled there. Varargs methods are occasionally useful, but Arrays.asList and/or Collection.toArray ensure that their absence is never a major problem. And see Bloch's Effective Java 2e (item 42) for warnings about over-using varargs.

Nothing in the current "Swing 2" plan has any real value to the developer of Swing applications, or to the developer's users.

It doesn't make existing stuff any easier to write.

It doesn't make existing stuff work any better.

It doesn't make it possible to write stuff you couldn't write before.

And what does "Swing 2" cost me, a Swing developer who's thinking of using "Swing 2" despite the fact that it doesn't do anything useful? Well, it costs me an extra dependency. A dependency on a fork of something that's under continued development. A dependency that won't auto-update itself with future Java releases; you'll have to re-release your application too. Oh, and I have to rewrite my source to be incompatible with what everyone else is using.

And that's as complex as your economic insight needs to be in this case. You look at what you're getting, and you look at what it's costing you, and you decide whether it's worth the bother.

The Nimbus LAF is an interesting contrast. It's equally worthless (if I wanted a LAF that looks like ass and shouts "crappy Java app", I'd use Metal), but Nimbus doesn't cost me anything except the engineering time that was wasted on it, and I had no influence over that anyway. So who cares?

You could accuse me of Python 3K blindness here. When that came out, existing Python users complained that it changed stuff unnecessarily, and even broke the "hello world" that's in all the tutorials. Am I not making the same complaint about "Swing 2"? No. What the Python old-timers were missing, I think (as someone who doesn't like Python, but thinks Python 3K is at least a little less bad than Python 2), is that while in the short term all the tutorials are broken, they'll soon be fixed, and everyone will be better off with a slightly less grody language. Python 3K aims to make things better for the future – where it'll be called just "Python" – at some cost to the past.

"Swing 2" doesn't improve the future, though, because it's a fork that will wither and die for lack of purpose. No tutorials will be rewritten, because they'll always have to refer to the One True Swing anyway. Anyone foolhardy enough to change their code to rely on "Swing 2" will end up changing their code back again, but don't worry: there will be precious few such people, and they won't be people writing actual applications anyway — those people will be worrying about stuff that actually makes a difference rather than unfortunate trivia.

If you want to do something that will make a difference, there are tons of things that are a real pain in Swing at the moment. JFileChooser, JOptionPane, JTable, and SwingWorker are all obvious examples of classes it's pretty hard to write a serious Swing application without, and yet all of which need to be taken outside and shot. And don't forget the ugly stepsisters JTextArea and JTextPane. You could write a decent replacement for any or all of those. Or you could look at some of the deeper stuff like the roles of ActionMap and InputMap and whether menus should really deal in Actions, and how the "Edit" menu works in Cocoa compared to how it never really works right in Swing. Or you could work on giving us abilities we don't currently have; an embeddable web browser with a sensible interface, that's available on all platforms, and that doesn't crash, say. Or you could try to address some of the difficulties of writing cross-platform Swing applications.

If you honestly think that using enums, generics, and varargs in the existing code are anything more than pissing in the wind, you need to read and write more Swing applications.

Or maybe try living without your little toolkit you've been using as a crutch that's prevented you from seeing the real problems. I personally never fight JOptionPane any more, for example, because I've written my own wrapper that beats some sense into it. But that doesn't mean JOptionPane is anything above awful. (This is the Python 3K blindness: it's harder for old-timers to appreciate how broken things are because they've got a good feel for where the dangerous swamps are, and ready-made duckboards for the areas they can't avoid. And aren't you supposed to get a bit wet anyway?)

The only advantage I can see of attacking the non-problems of enums, generics, and varargs is that they're easy problems. Imagine, by comparison, the amount of work involved in writing and maintaining your own JTextArea replacement (like the jessies.org one). And that's a tiny project compared to any reasonable "Swing 2". If you don't have the stomach for one of these wafer-thin mints, you can forget about anything as grandiose as "Swing 2".

Don't get me wrong: you can "fix" these trivial API warts, but you need to provide something worthwhile to go with those changes. If people were already using "Swing 2" because, say, it had a JTable replacement based on Glazed Lists, they might then swallow the trivia. But try to do things the other way round, and your project is stillborn.

Although, given that the currently perceived "enemy" of Swing is JavaFX, you might even want to revisit the very premise of Swing and ask whether we shouldn't really be talking about "AWT 2" instead of "Swing 2". In a sense, JavaFX is Sun making the Swing mistake all over again. (The main difference is probably that last time they were too early to the party; this time they're too late. And at least this time I haven't heard them say it'll be okay for the desktop too.)

2009-02-07

Mistakes MS makes when asking for my money

Ars Technica recently ran an article "Four things Sony can do to turn the tide for the PS3 in 2009". I don't have a PS3, but I do have some ideas for Microsoft about how they could get more of my money without making me feel like I'm constantly fending off their incompetent attempts to mug me.

No special cables
Feel free to sell special cables, because there are idiots buying $200 HDMI cables right now from the tech equivalent of homeopaths, and they may as well throw their money at Microsoft. But don't screw the rest of us by designing the back of your console so we can't get optical audio and HDMI out without hacking our component cable to bits.

No special hard disks
Feel free to sell special hard disks, but let me attach my own, too. $140 for a 120GiB drive? I can get a 1TiB drive for less than that. I'd have to make an effort to find a drive as small as 120GiB, but it looks like the going rate's about $40. Charging twice that would be cheeky, but three times?

Fix the music UI
Of course, I'm happy with the 20GiB drive drive that came with my 360, because the UI for navigating music is so awful I'd have no intention of putting music on the 360 even if I didn't have a house full of machines with more than enough storage.

Stop charging for Netflix
I'm a Netflix subscriber. I pay Netflix money each month, and they send me DVDs. They also let me watch stuff on my Mac. I can plug my Mac into the TV, and I can play the DVDs on my 360 (or the Mac). So it's not like Microsoft is adding any value there, from my perspective. So why do I have to pay Microsoft an additional annual $50 fee before I can watch Netflix movies on my 360?

I realize it's not a large sum, but you've not done anything to deserve it, so asking for it makes you look bad.

Stop making me wait for demos
When I first got a 360, all you had to do to download demos was sign up. And I thought that sucked. Why should I have to tell you all those details about myself? Great way to put off a casual user.

But it got worse. At some point, Microsoft decided that only paying users should have the demos straight away. Free users should be punished by being made to wait a week.

The advertising doesn't present it like that, of course. Just today, I was told I could get "early access" to some demo. But I know I only have to wait a week, so why would I pay anything for this? Again, there's a distinct lack of class evident here.

Mandate demos
So here's why making me wait for demos is stupid...

When a game first comes out, it's $60. If you're over the age of 12, you'll have noticed that sooner or later, that $60 game will be $50. Then $40. Then $30. And then it's a toss-up between going down to $20 or just disappearing. And these are the new prices I'm talking about. You can also buy used, or rent, or borrow (look for these options to disappear when games leave physical distribution behind).

So let's assume you want to sell at $60. How do you do that? You get people excited. How do you do that? You give them a little taste. Make them want more.

In more reputable lines of business, this is known as "the first one is always free". In video games, it's called "playable demo".

And here's the funny thing: Microsoft has this big list of things you must and must not do to be allowed to sell a game for their console. So you must support "achievements", say, and you must not show erect penises. Stuff like that. And one of the things Microsoft don't see fit to insist upon is "you must offer a playable demo, at no cost, via Xbox live".

Maybe this is to protect games that stink, but I doubt it. And who's to say which games stink anyway? I like FPSes, you like flight simulators, she likes RPGs, he likes driving games. I liked "Fracture" more than "Star Wars: Force Unleashed". I liked "Crackdown" more than either, but – because it was labeled as a driving game (which it really isn't; you can finish the game without driving at all, though you can't get all the achievements without getting in a vehicle or two) – I would never have bought "Crackdown" if I hadn't been able to play a free demo via Xbox live.

There's a related situation playing out right now. Reviews say "Left 4 Dead" is great, despite the illiterate boy-band title. I'm mildly interested. The similar game "Resident Evil 5", which hasn't been reviewed yet because it isn't out yet, has a free demo available via Xbox live. I have played this game, and I am excited about it already, and I'm going to buy it. If the missus plays the demo and doesn't hate the controls too much, I'll buy it even sooner.

"Left 4 Dead"? Left for dead. No demo, you see.

The really funny part is that I almost forgot to play the "Resident Evil 5" demo. I mean, it's labeled "survival horror", and I hate survival horror, but I make an effort to play all co-op demos. How did I almost forget? Because MS made me wait a week. A week's a long time when you're a grown-up with a job.

Speaking of survival horror, I love sci-fi, but the survival horror side of "Dead Space" meant I knew ten seconds in to the demo that this was not for me. And that's a good thing for EA, because I won't buy that game and think "EA sucks". I'll buy "Mirror's Edge" instead, and think "EA's okay".

Don't get me wrong: I know you can lie in a demo. But the essence always seems to show through. Some of the shine was taken off "Mirror's Edge" for me when the guns came out and people started shooting. I just wanted to run about. And the demo for "Star Wars: Force Unleashed" showed me both what I'd like and what I'd hate about the game. "Stranglehold" was probably the most misled I've felt. If the game had been like the demo only longer, I'd have been happy. But the game got harder and more arbitrary until it was just a frustrating chore. The demo was too short to show that.

But demos are a game's best chance of getting me to buy them before they hit the bargain bin.

Look to the future
The DVD is the last read-only physical medium. BluRay may have won the battle against HD-DVD, but it lost the war against irrelevance. Large amounts of local storage are cheap. Bandwidth is plentiful and becoming more so. Start selling me a subscription service now. Games, like movies (and unlike music), are perfect for subscription. Only a hardcore few want to play the same game over and over, year after year. Most people will play a game, "finish" it, and cast it aside. Right now, many will do that in a way – selling it used – that lets other people buy and play the game without anyone involved in making the game seeing any of that money.

So let me subscribe, and let my subscription allow me to play whatever games I want, whenever I want. This is the only reason I'd ever pay for Xbox live. I don't want to play online with juveniles who'll call me a Mexican Jew lizard. I'm insulted by the suggestion I should pay money to be allowed access to demos, the sole purpose of which is to get me excited about paying money to buy the real thing.

But a "Netflix instant" for games? That would put your attach rate through the roof. It would get me hooked on more of your platform exclusives, just as the promise of "Halo 3" and "Fable II" made the choice of which console to replace the original Xbox with pretty darn easy.

(The funny part here is that the missus is living in this world already, happily playing free Flash games in the browser, via our "subscription" to the internet. And that's definitely eating into her 360 time, and the less time she spends on the 360, the less progress she makes in her 360 games, and the less progress she makes, the longer until we buy her next 360 game. I don't know if Microsoft understand yet that it's not just the PS3 and Wii they're competing with; it's MySpace and YouTube and a bazillion websites with crappy Flash games. Hell, you can't even browse the web on the 360, for no obvious technical reason. An internet-connected device in 2009 that can't browse the web?)

Let me skip tracks
Finally, for now at least, one last request. Let me skip the boring bits. As the Ars Technica article said (meaning something different entirely) "remember that games are for fun". Don't force me to keep replaying the same tedious boss battle, let alone the five minutes of tedium between the last checkpoint and the boss battle itself, or the unskippable two-minute cut scene some genius sandwiched between the two, or make me suffer any of the "shitty bits" I keep finding in my games. Let me say "skip this", rather than forcing me to suffer, or, in some cases, forcing me to just give up on the game entirely. Boss whose arbitrary rule you can't work out in a game no-one else liked well enough to write a walkthrough for? Sorry. Game with automatic checkpointing saved your game when you had no health/ammo or were lacking the necessary weapon/item for the next section? Sorry.

Looking back, all of these strike me as reflecting a basic lack of respect for the customer. We're just a bunch of nameless, faceless chumps to be milked (or mugged) for everything they can get. It may be the traditional way of business, but I'm unconvinced it's a healthy way, and I very much doubt it's even the most efficient way of transferring our money into their slush funds.

I suppose I should be grateful the current generation of consoles aren't coin-operated.