Categories
Industry Technology

Historical design decisions and consequences

Douglas Crockford discovered JSON and he also wrote a reference implementation for JSON in Java. One of the great stories I heard him share was on Hanselminutes episode 396: He was contacted by some developers that were getting syntax errors while parsing JSON using his reference implementation. It turned out that they were transferring JSON documents more than 2GB in size but the Java implementation was using a 32 bit integer to keep track if the number of characters in the JSON document. The maximum value of a 32 bit int in Java is:

2^31-1 = 2.147.483.647 ~ 2 billion = 2G

So because 2GB of data has a higher number of characters than can be stored in a 32 bit integer, that was obviously a problem. As Douglas Crockford says in the podcast, he had no idea that anyone would ever use JSON to store so much data yet it happened anyway and all of a sudden it was actually a bug.

Historical design decisions and their consequences for modern day computing are very interesting and I recommend listening to the entire Hanselminutes show through the link above. I just wanted to share a recent example of the same kind of problem. Here is a screenshot from the landing page for Rocksmith (a guitar hero kind of game but with a real guitar):

Rocksmith splash screen

The interesting part of this screenshot is the highest arcade score. It is exactly the maximum value of an int (2.147.483.647). I do not think it is a coincidence. I think the Rocksmith developers simply did not think that anyone would ever get more than 2 billion points in the arcade game and it was probably a fair guess. I could be wrong of course, but it is still a good reminder that even small decisions like choosing a datatype to keep track of a score has consequences for the software we produce.

Categories
Technology Tips

Ubuntu — not ready for primetime

I wanted to install Ubuntu on my Dell XPS 15 to try out Steam for Linux. This was not the enjoyable experience I had hoped for since a lot of things did not work perfectly out of the box. Below are some steps I had to take to get the system going.

Fixing the graphics

My laptop has NVIDIA optimus technology which automatically switches between Intel’s HD 4000 graphics card and the faster NVIDIA Geforce GFX 640. Apparently, optimus support on Linux is not good.

In Ubuntu, I had no 3D support and the graphics would spontanously turn off after a restart so I was presented with only the terminal. Fortunately, there are some nice people that are maintaining a project called Bumblebee which adds support for optimus in Linux. After installing this, my graphics system has been fairly stable. Just do this:

sudo add-apt-repository ppa:bumblebee/stable
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic

I also recommend the primusrun package:

sudo apt-get install primus

With the above installed, it is possible to run programs specifically with the NVIDIA card like so:

optirun glxspheres
primusrun glxspheres

Fixing the mouse

Yes, the mouse did not work. Well, the touchpad worked but my wireless Logitech M705 mouse did not. The problem, it turned out, was the Logitech Unifying Receiver. It is a small USB thing that is plugged in for a mouse and external keyboard and is used for many Logitech devices. After searching for many hours, somewhere on some forum, I found the following simple command-line trick:

#!/bin/bash
while :; do dmesg|grep logitech-djreceiver|tail -1|grep -q -c "failed with error -32" || exit; echo -n `date`" Driver Reload" ; rmmod hid_logitech_dj ; modprobe hid_logitech_dj ; dmesg|grep logitech-djreceiver|tail -1 ; sleep 1; done

You can also find it as a github gist here.

The script simply tries to reload the receiver with modprobe and it works. Sometimes after one loop, sometimes after ten. And it is a pain in the ass to run it at every startup.

Getting Steam to work

The real reason I wanted to try Ubuntu again was the recently released Steam for Linux client. After installing Bumblebee, Steam actually installed and ran quite well. However, it is worth taking a look at this guide for running programs with optirun/primusrun.

Conclusion

In the above, I left out the fact that before finding the solutions, I had to reinstall Ubuntu three times because of playing around with graphics drivers that broke the system until finally figuring out about the Bumblebee project. This is definitely something most users would not want to mess around with. Not only that but my mouse is still not working after a restart and sometimes I am still greated with the terminal login instead of a graphics login. It is quite random, actually.

I should also note that I have had similar experiences with Ubuntu in the past. I love Linux but it just does not work like Windows or Mac. As soon as you are faced with a weird hardware problem, good luck fixing that without the command-line!

Therefore, I have to recommend not installing Ubuntu at the current time — at least if you have dual graphics card with optimus technology or you are not willing to spend hours trying to fix things. It is a big shame because the Linux platform and Ubuntu in particular shows great promise. But it is not for everyone. It is not ready for primetime.

Categories
Industry Technology

Why you should not use Microsoft Silverlight for your next web application

You are running a Silverlight 4 application. You may experience incompatibilities as Moonlight does not have full support for this runtime yet.
The above warning message sums up everything I dislike about proprietary web technologies. Silverlight is a fairly new Microsoft technology from 2007 and Moonlight is its Open Source and not up-to-date equivalent that I have to use because Microsoft does not provide Silverlight for Linux. Since most software only run on Windows anyway why is this so upsetting? Well, everything is different on the web.

First, the premise for Rich Internet Applications (RIA) like Silverlight, Flash and even Java is ok: A website usually does not provide much “action” in itself so having an extra plugin running on the website with some access to the underlying system resources as well as built-in extra functionality will provide a better user experience. Microsoft writes on the Silverlight website:

Silverlight is a powerful development platform for creating engaging, interactive user experiences for Web, desktop, and mobile applications when online or offline

That sounds good and I do not necessarily disagree with the premise for RIAs but the question is: Why did we need another RIA platform that doesn’t really work? I don’t exactly know. However, it is understandable from Microsoft’s viewpoint, given their history of locking-in people to their platforms and the fact that they have legions of .NET developers that are probably very comfortable staying in their own environment when writing web applications. For them, Silverlight is probably bliss.

But there are some problems, one of them being its availability. As of this writing, Silverlight is only supported in roughly 61% of all browsers, according to statowl, or roughly 69%, according to riastats. As the above warning message suggests, it does not work perfectly on (my version of) Linux, even with the newest Chrome browser and Ubuntu 11.04, the arguably best supported Linux version out there. Indeed, most of the Silverlight applications that I have looked at did not work very well, including an app that I was offered to work on1 and popular services such as Netflix which currently does not work with Moonlight.

Again, the question arises: Why is this so bad? Isn’t this the same as always? No, it is a problem because the beauty of the web is its openness, and this openness is what Microsoft is challenging. The same applies to Flash. You may call Apple snobbish and manipulative if you like but Steve Jobs does have a point regarding Flash as a platform:

Most Flash websites will need to be rewritten to support touch-based devices. If developers need to rewrite their Flash websites, why not use modern technologies like HTML5, CSS and JavaScript? … New open standards created in the mobile era, such as HTML5, will win on mobile devices (and PCs too). Perhaps Adobe should focus more on creating great HTML5 tools for the future …

In my opinion, this would apply to Silverlight also. To be fair, Microsoft is embracing standards like html5 in Internet Explorer 9 but at the same time, they continue to push Silverlight forward. Some people think that this is not a problem since html5 and Silverlight are not direct competitors. But because of Microsoft’s power, Silverlight applications are shooting up everywhere which cuts off some users from using certain services of the Internet, something we have not seen on the same level with Flash. And this is a troubling development.

There is only one way of avoiding that Silverlight will dominate the next decade of web applications as Flash did in the past: Stop developing applications for it. My choice should now be clear. But I fear that I am almost alone.