Kai.Jaeger.Blog

Jun 21, 01:11 AM by Kai Jäger

Now in color

After living with the same blog template for two and a half years, I decided that it was time for a change. So today I present to you a much friendlier, much more colorful kaijaeger.com. I hope you like it. If you don't like it: tough luck, because the old one is not coming back. Nonethless, let me know what you think.
Jun 07, 15:01 PM by Kai Jäger

Technology is amazing

So today I was walking through the park, tracking my GPS position on a high-resolution satellite map that I was streaming over a high-speed wireless internet connection directly to my cell phone, when I finally realized what it means to be living in the 21st century. It’s not about flying cars (although those are cool) or robots, it’s about the availability of information. Remember when you had to go the library to learn about a particular subject? Or when you had to look in the yellow pages to find an address? Or when you had to go to a store to find new music? Or when you had to use a crank to start your car? Well I do (maybe not the crank thing), still I’m taking all this crazy new technology completely for granted. And it’s not just me: pretty much everybody I know who owns a computer is completely dependent on it without even realizing it. I’m not saying that’s a bad thing (although it probably is), I just think every once in a while we should all think back to how life was before the internet and then go “I can’t believe how awesome this is”.

That said, I can’t wait to read this article again in a few years from now and laugh at how archaic technology was “back then” and how much greater it is now.
Jun 03, 01:08 AM by Kai Jäger

My new life as a smartphone owner

After contemplating about it for quite some time, I finally got myself a smartphone today. This of course makes me the ultimate hypocrite: just a few years ago, I had no cell phone at all. When asked about it, I would say that I was opposed to the idea of being "available" wherever I went. After I had gotten over that, I went through a couple of cheap pre-paid cell phones and finally got myself a proper phone just about two years ago. Of course in the meantime, the iPhone had come out and while I liked its slick design and the nice UI, I felt that it was too bulky to be useful... "and besides, who needs all these features? It's a phone for christ's sakes!" But when mobile internet became affordable, all of a sudden, the idea of owning a smartphone didn't seem so silly after all.

So which phone to pick? I decided that if I was going to get a cell phone that is essentially a computer, I wasn't going to let anybody tell me what application I could run on it. Specifically, I wanted to be able to write native code applications and run them on my phone without jumping through too many hoops. To my surprise, Windows Mobile (and to some degree Symbian) seemed to be the only platform that supported this and with Windows Mobile support built right into Visual Studio, I already had all the development tools I would need. Unfortunately, Windows Mobile was designed to be used with a stylus and that was a big turn-off for me. Enter the HTC Touch Diamond, a Windows Mobile phone with a proprietary touch-optimized UI. Long had I drooled over this phone until the successor, the Touch Diamond 2 was both announced and released. And now I'm glad I didn't get the HTC Touch Diamond because the Touch Diamond 2 is just infinitely more awesome. That's right, I am now the proud owner of an HTC Touch Diamond 2.

The Touch Diamond 2 is a stunning piece of hardware from its 3.2" WVGA (480x800 pixels, 290 ppi) screen to its 5 megapixel camera. It's a 3G phone, has GPS, a built-in FM radio, a second forward-facing VGA camera for video conferencing, a replaceable battery and a MicroSD slot, an accelerometer... it's essentially an experiment in how much cool technology you can pack into 107x53 centimeters (there's a dirty joke somewhere in there). Oh, and it runs ScummVM which means I can play all my favorite point and click adventure games from the 1990s while waiting for the subway train to arrive. How cool is that? Very cool indeed.

And now to answer the ultimate question: does a smartphone really make you smarter? I'm not sure, but I can now Wolfram-Alpha that for you wherever I go.
May 24, 23:11 PM by Kai Jäger

scribblet - a bookmarklet that lets you scribble on any web page

Before yesterday, I hadn't written any JavaScript code in a long time. So I finally decided to implement an idea that I had been thinking about for quite a while: a bookmarklet that turns any web page into a canvas that you can scribble on. I got the idea from a Firefox mouse gestures addon that can show a trail of your gesture as you draw it. I often use that "feature" to create scribbles, but unfortunately the mouse trail disappears once you release the mouse. Scribblet works exactly like that, minus the disappearing trails and plus a bunch of useful features. You can scribble on any web page and you can email your scribbles, too.

Technology wise, scribblet has been an interesting challenge. Because bookmarklets are essentially URLs containing JavaScript code, they can't be very long (they can be in most browsers, but not in Internet Explorer). To be more precise, a URL in Internet Explorer can be at most 2,083 characters long. That means the entire "program" has to fit into a little more than two kilobytes. With the use of JavaScript minfication tools this becomes somewhat easier, but you still have to think hard about every single line of code that you write.

So what would you use scribblet for? I can imagine a whole bunch of scenarios, but primarily you would use it to annotate web pages for customers, web designers that you have hired and probably your parents ("Just click the link in the left column", "There is no link in the left column", "sigh"). Also, if you encounter a web page that you don't particularly enjoy, you can use scribblet to express your dislike...
Feb 01, 19:27 PM by Kai Jäger

JSINQ – an implementation of LINQ to Objects in JavaScript

Two qualities that I like about software in general are simplicity and elegance. Unfortunately, most of today’s software is neither simple nor elegant. People generally argue that it’s impossible to write simple software when customers are asking for a lot of features and therefore for a lot of complexity. Of course they’re right, but they’re also wrong. Simplicity and complexity aren’t mutually exclusive; in fact, all complexity is built from simplicity. Think about CPUs for example. CPUs may be among the most complex devices ever conceived by humans, but at their core, they’re built from logic gates which are actually quite simple. The key to building complex systems that work is to found them on a small set of rules that are simple and elegant. I’m only just beginning to realize that, but so far, the experience has been great.

Some time ago, I was given the assignment to prepare a talk about LINQ, the language integrated query component of Microsoft’s .NET framework. In all honesty, I picked the assignment myself, not wanting to talk about some arbitrary XML framework which would have been the alternative. LINQ was something I had been interested in for a long time. It’s essentially a DSL for querying various data sources including RDBMS tables, XML documents and in-memory collections. What struck me about LINQ though was the fact that it isn’t so much a DSL but a library and if you step back even further, it’s actually more of a design pattern. LINQ was co-invented my Erik Meijer who is also heavily involved in the development of Haskell. Now I don’t know Haskell, but I know of it and I quickly realized that LINQ wasn’t much more than applying some of Haskell’s most interesting language concepts to C# and VisualBasic.NET. What I also realized was that LINQ at its core is just a clever way of composing functions and that gets me back to simplicity and elegance. If you look at LINQ from close up, you’ll see a bunch of magic and a lot of complexity. Take a step back and it all dissolves into simplicity, elegance and even beauty.

When I was preparing for my talk, I decided that I wanted to have a full understanding of how LINQ worked and so I finally came to the conclusion that the only way to get there was to implement it myself. What came then was a crazy two day frenzy. I forgot to eat, I forgot to sleep and when I tried to sleep, I couldn’t because of how excited I was. After those two days however, I had a complete and fully tested implementation of LINQ to Objects minus the expression compiler (I’ll get to that in a second). I gave the talk and despite the insomnia I felt very confident. Also, I felt like I had entered a different world (hi, my name is Kai and my drug is sleep-deprivation), seen the light or whatever you want to call it. I had seen the elegance and simplicity of LINQ and it was awesome.

Then came the realization that while the LINQ library by itself was a nice thing to have, writing queries with it was actually quite awkward (because of JavaScript’s verbose lambda expression syntax). So I decided to write a LINQ compiler that would translate LINQ-style queries into JavaScript code. I’m going to spare you the exact details of how that compiler was implemented, but it was both an enlightening and an exhausting experience. I finally got to do something with parser combinators which was great fun, but writing the actual compiler turned out to be quite tricky.

Anyway, my JavaScript implementation is now done, it is inappropriately named “JSINQ” and I’m sharing it with all of you in the hopes that you might find it useful. Let me know what you think, be sure to report any bugs you may encounter and of course: stay in school.