Monthly Archives: January 2009

TV’s are small, plus a little Clutter

So I was sitting watching my 40″ HDTV the other day, and started thinking about why web browsing on a TV pretty much sucks, even with all the pixels you get at 1080i or what have you. And trust me, I tried it with our PS3 and other than watching YouTube videos, it’s not a good experience.

But while I was sitting there on my couch (or sofa, depending on your English dialect) a pretty normal distance from the TV, I held my hands up to frame the size of the picture at arms length. Then lowering it to may lap, it struck me. The size of the picture isn’t any bigger than a handheld gaming box, maybe slightly bigger than an iPod Touch (as I try to find one for my son’s birthday on Thursday 🙁 ).

The reality of the situation is that even with the higher pixel count, you still need to treat set top boxes as mobile, but not mobile, internet devices and entertainment units. And that especially goes for the UI. Don’t try running GNOME on it, that’s going to be brutal.

So I’m off taking another look at mobile devices and the user interfaces they present. The newest one is the 2.0 alpha release of Moblin, Intel’s effort at a Linux distro for mobile internet devices and netbooks running their chips. The video in the LinuxDevices.com article is intriguing, and made me go look at what technology they were using to present their 3D animated GUI.

Well, it turns out to be another open source project called Clutter. They produce a library that abstracts away the grunge of OpenGL and OpenGL ES to build user interfaces. You create Actors that have images and such and declare their animation and event handling and then fire off into an event/display loop. You get pretty cool effects with not too much code.

Now, I have to pick at the choice of GTK as their paradigm mentor and, yes, if you’re used to GTK programming, doing Clutter will be natural, but if you’re like me and fell in love with the Qt and it’s elegant use of C++, then you’ll be a little put off. I did find a clutter-qt integration in their repo, so maybe you’ll be able to do both in the future.

Someone once said, and I think he lived in Redmond, Washington, that there was no innovation in open source. This is a pretty significant counter to that. This project has been around for a while, sprouting out of the need to add GUIs on top of the new fancy 3D graphic chips appearing in handheld devices. They have a innovative and game changing solution. The just need people to discover them, and Intel, who also happens to be their new boss, is helping with that.

Can an LGPL Qt give C++ a lift?

Black Duck recently announced their top Rookie Open Source projects for 2008 which using a bit of a weird metric, revealed the top 10 open source projects that were created in 2008 that had the highest number of releases. More releases makes you good? O.K…

Anyway, the most interesting information from their news release was the stats they gathered on what programming languages these new projects were using. To the surprise of many, 47% of them were written in C (C Rules!). That was followed by 28% in Java and 20% in JavaScript. It’s pretty interesting there was so much JavaScript usage. And again, these were projects that have just been created. But when you look at it, most open source projects target Linux, and by far the most popular language for Linux is still C.

One thing I noted, though, was that C++ wasn’t even mentioned. It could be that they lumped C++ in with C, but I have my doubts. I rarely do see C++ in open source. The large open source game engines, like Ogre and Irrlicht as well as Firefox (of course), are in C++, and OpenOffice is written in every language imaginable including C++, but I see C way, way more.

[Watch out, bad segue ahead…]

I spent part of last weekend taking a deeper look at Qt, with its upcoming spanking new LGPL license. I have to admit I’m a GPL library bigot and kept away from Qt because of that, but boy do I regret that now that I’ve seen it. It’s an incredibly complete C++ library for building apps of all kinds. And it has everything I’ve been looking at lately, WebKit, JavaScript (well ECMAScript but that’s the same thing), and OpenGL, and incredibly smooth integrations between those and many more components.

So as Qt makes this transition, I have a feeling it’s going to gain in popularity everywhere. And I think it’ll show the power of C++ and pull a lot of the developers writing for the C-based GTK away. Heck even Ubuntu is thinking of switching to it for their mobile platform.

Kudos to Nokia for making this decision. I think it’s going to pay dividends for them as developers take a fresh look at a great framework. Which, BTW, means there will be more developers working in the same environment that also happens to run on Nokia’s phones ;).

J2ME? Why?

I was just reading the slides presented from the kick-off meeting of the Eclipse Mobile Industry Working Group. I believe this is the first working group at Eclipse and I think it’s a great concept. Bring groups of companies together that are interested in the same or similar technologies and do some planning. Hopefully that will result in new investments in various Eclipse projects.

Anyway, one of the examples of work environments shown was for a J2ME developer. The first thing that jumped into my head, and of course I’m writing this entry without thinking more so I may come off a bit misinformed here but hey I’m just the dumb C++ guy, but who cares about J2ME any more? With the rich mobile development environments provided with Android, the iPhone, the new Palm Pre, and even Qt for mobile devices, why would you do J2ME development any more. Isn’t there much more opportunity for greater riches writing apps for these new and wildly popular environments?

Anyway, feel free to comment and tell me the way it is. And I’m sure the J2ME people over in DSDP are the right people to do that ;), since they know that community. But I am curious about whether the J2ME community is still on the rise, or whether there is a migration happening to these new technologies.

Time to Get Qt?

Now this is interesting. I’ve mentioned a few times in my blog that the world would be a different place if Qt was given a free commercial friendly license, like LGPL. Of course when Trolltech was an independent company, that would have killed all their revenue. But now that they’re owned by Nokia, I guess the time has come for them to make the change.

And I think this will open people’s eyes to Qt. It’s certainly a very rich framework giving pretty much everything you need to make a truly cross platform application, i.e. #ifdef free. And it’s used in some very popular applications like Skype, Google Earth, and the VirtualBox manager. And, of course, it’s the foundation of the Linux KDE desktop environment, which has it’s devoted fans.

And again, being LGPL, I’d expect to see it used by more commercial applications. Heck, it will now pass my policy and I’ll be able to include it in Wascana, and the SWT developers will also be allowed by their lawyers to write the port against it. Who knows…

But as I scout the horizon of desktop and mobile apps, I wonder if the apparent momentum away from C/C++ has become too great for this to make a significant splash, or will it just be a ripple. Maybe my head is too deep in WebKit these days and my view is getting tainted, but the web is slowly taking over. I guess the one thing Qt has going for it is a decent WebKit integration so maybe they can get the best of both worlds. Either way, it’s definitely time for me to take a deeper look at Qt (and it’s CDT integration, of course ;)).

Palm Pre and WebKit

I’ve been following the Palm Pre story a bit the last few days. While the technical details are still pretty sparse, it appears that one of my predictions for 2009 is already starting to happen.

My understanding, and I hope it isn’t coming from sources who are also using the same technique to guess at the architecture of this thing, is that the UI for the Palm is rendered totally using WebKit. It appears that the applications for this device are written in JavaScript and use HTML and maybe WebKit’s SVG support to render the graphics. Hell, maybe it’s even using Dojo to make things look really sharp.

If this is true, then it’s going to be a great test of how well this architecture works. I have my worries about how JavaScript scales and how easy it is to write traditional GUI apps, even handheld ones, using HTML as a rendering engine. But looking at the screenshots, it looks pretty awesome.

The other thing I notice is that there is a continuing trend of making it very difficult to build native apps that draw on the screen with these things. It started with JavaME in the “old days” and is continuing today with Google’s Dalvik Java VM and now Palm’s WebOS WebKit thing. They promise the power and openness of Linux and then shut the door. It’s too bad, since a lot of these handhelds have 3D graphic acceleration in their SOCs, and you really need to go native to build a good 3D game or what have you.

I can’t wait to see what the Pre SDK looks like, and whether developers buy into this architecture of GUIs based on web technology. And it’ll be interesting to see how good the apps can be with it. But if they’re as good as the prerelease demos, it’s something to pay attention to.

Zune 30, Killed by Complexity

I first heard of it early New Years Eve, I guess. Hoards of Microsoft Zunes were committing mass suicide (a gruesome thought but the actual quote from the Slashdot article). Fears rose that some Y2K thing was happening, mind you things like that didn’t happen in Y2K, at least not on this scale. Microsoft finally confirmed the issue as such though, a device driver hang on the 366’th day of a leap year. I’d love to see that code…

Well, thanks to the wonders of the internet, here it is! (I imagine this link will fall dead as soon as the Microsoft cronies make the rounds, as they should. It does have a Microsoft copyright). I actually found it through another blog where the guy put together a pretty good analysis of the problem.

The root cause? A brain fart. Either someone was in a hurry, or they couldn’t handle the complexity of the algorithm once they started dealing with leap years. People blame testing for not testing all the paths. But, if you don’t take the time to test all the paths, or don’t have the skills to properly enumerate all the paths, testing isn’t going to matter. At any rate, another great software engineering lesson learned for us all, just like the unhandled exception in the Ariane-5 rocket, except this one is recoverable and isn’t as expensive (unless the Zune market share dives as a result, which could happen).

I spend a lot of my time these days working on software architectures and trying to come up with the most simple, extensible, and future proof. But none of that matters if you have code like this. And I’ve seen code like this all through my career. Hell, I’ve written some of it. But one thing I learned early from one of my great profs back at the U of S, was on code complexity. It is even measurable by counting the number of paths through your code. Complexity bad. Which implies that having more paths than you need is bad. As we see here, it becomes too difficult to test fully.

And that is certainly the case here. Too many ‘if’s. How do you convert days since 1980 into a time structure? Well in the Zune code (which is actually a common device driver in a number of Windows CE platforms), one of the paths leads to an infinite loop, when days is 366 and IsLeapYear is true. The author of the blog proposes a much simpler algorithm that works correctly but reduces the paths thus eliminating the bad one. I think you can make it even simpler.

One of my mantras is “I hate typing!”. Of course it has nothing to do with typing (much). It’s about producing simple elegant solutions to simple problems. Yes, Keep it Simple S(favorite ending here). Saves time. Saves money. Saves embarrassment. Saves your job. I’d hate to be the guy who wrote this code…