Code Generators

26. August, 2009

Code generators can save a lot of time and effort which leads to the question: Why isn’t everyone using them? A lot of code in any project is repetition.

The main reason: With todays IDEs, you can’t debug generated code. Well, you can debug the result of the code generation but when hunting bugs in generated code, chances are that you want to hunt them in the input and/or the transformer and no IDE has a notion of “this line of code came from these inputs, so show them as well”.

Example: You need POJOs which map database tables. Easy enough: You create a small program that connects to the database, maps the types in the tables to types in your favorite programming language (or rather the one you have to use for your project) and dump some code.

But unlike C/C++, modern languages don’t have a #line directive which says “this piece of code was originally part of another file” let alone “this information came from the database XXX”. So when there is some problem, you need to dig through the layers of the code generator, the templates and the input (the database) yourself, running the transformation in your head. Bad.

Approaches like MDD will keep failing until they support this.


Batman: Arkham Asylum (PS3)

24. August, 2009

Even for the many definitions of fun. For example, there is a new game “Batman: Arkham Asylum”. I was really hesitant to download the demo. And then, I was hesitant to install it. Why? Because the trailer gave me the impression “another super hero beat ’em up”.

Okay, the in game cut scenes look great. Clothes have texture and the outline of the characters doesn’t reveal the 17-poly mesh. During the demo, it quickly becomes evident that a lot of resources went into the combat scenes where Batman does move pretty smart. You select a general direction and the type of attack and the Bat will do some serious damage. It feels like you actually control someone who spent years training martial arts, not some stuffed puppet. Using the grappling hook works like charm, even without much aiming. It’s enough to be close one of the gargoyles and it’ll work like a charm. Well … gargoyles in the building? Anyway.

That changes when you start walking around the compound. Here, the stuffed puppet is back. You can run which makes things better but the walk cycle looks really unbelievable. Did you know that Batman can’t jump? Maybe it’s because of the heavy belt? Or the muscles are all part of the suit’s armor? No climbing either. If you don’t have something where your grappling hook can attach to, you can’t even climb on a chair.

But what I was most afraid of: “The world’s greatest detective.” Remember? After taking the first round of inmates down, I almost gave up on the game. Only it does get better. There is something called “detective mode” which highlights interesting features around you (like enemies, things you can use your grappling hook on, etc). So after the short scene with Victor, the game turns into something that resembles Metal Gear Solid. Not bad. While you can try to take down everyone with a gun, you probably shouldn’t. Just as in reality, when you beat up one out of five people, four will start shooting you in the back.

There is still hope.


10 Ways to be a Better Thinker

20. August, 2009

There is an article on CNN about ten ways to be more happy with your brain.


UI Design: Why is That Button Gray?

13. August, 2009

Here is one tip for your UI design that can really make life easier for your users: “Why is that button gray?” – or smart tooltips for disabled elements.

One additional comment: The tooltip shows a lot of information why the button is disabled. Why not simply set the right tooltip in the save place where you disable the button? At that time, you’ll know exactly why you do it and you can give the user specific directions what to do now (instead of having her read and pick from a list).


Two Jokes

6. August, 2009

Announcement from [your-favorite-dictatorship-of-the-week]:

After years of scientific progress, we finally managed to turn a wagon load full of human waste into butter. A great day for our country and the whole world. Next, our scientists plan to work on the color and the taste.


A man suspects his mother-in-law trying to poison him. To confront her, he feeds the lunch to his dog. The dog drops dead instantly. The man, mad with rage, stabs the mother-in-law to death. As he stands over the corpse, breathing heavily, the dog jumps up and barks: “YES!


An Interstellar Transport System

3. August, 2009

Mankind has been dreaming about an interstellar transport system for a long time (some were nightmares). There are a lot of ideas around which use exotic matter, worm holes, etc. A few years ago, a colleague proposed something much more simple. It works like this:

Take a body in our own solar system and drill a hole to the center. Earth is a bit too hot but the Moon would work. Mars would be better but that’s too far away for a first prototype. In the center, build a chamber which can be isolated completely from the outside. That would need a lot of technology but it should be possible to create a room where an object would not be influenced by any external forces or any information exchange (photons).

Next, you create a similar chamber in a second place. This can be anywhere in the universe. Distance doesn’t matter. Only that you have two places that you can “seal” from the rest of the universe.

Now the trick: You put an object in chamber 1 and measure whether it is still there. You do the same in chamber 2. There are ways to measure with slightly different probabilities for whether you’ll find an object or not. This is a quantum effect. In chamber 1, you’ll use an effect with a slightly higher probability that it will return “nothing here”, in chamber 2, you’ll use a method with a slight lean towards “object is here”.

In normal physics, this is ridiculous but not at a quantum level. At a quantum level, as soon as you completely isolate an object from the outside and make sure that no information whatsoever can be exchanged with the surrounding chamber, it doesn’t matter anymore in which chamber the object really is. You have created a really huge qubit, a system where nobody can say anymore at which place the object currently is.

In that very moment, as soon as no one can tell, the universe will stop caring and by using the clever measurement technique, you constantly nudge the object to “jump” to chamber 2. After a long but finite number of measurements, it will be gone from chamber 1. And if no other alien race came up with the same idea, it must now be in chamber 2 because that’s the only other place in the universe where it could be.

If you wonder why we had to drill to the center of a moon or planet: That’s the only place in our solar system where no gravitational forces pull at an object (gravity would also count as “information exchange”). You could try a Lagrangian point but there, you’d have a hard to time to shield the object from all the radiation in space — the mass of the moon would do that for you. Next, you’ll need to cool the chamber to absolute zero to prevent heat photon exchange and you’ll need a large blob of water to shield the chamber against neutrinos.

As far as I can tell, the only hole in the theory is microgravity: Will it be possible to shield the object from the tiny gravitational forces that still exist even at the core of a big object in free fall? If the answer to this is yes, then we might have an interstellar transporter which is even pretty efficient. Transport will take some time (until the way of measurement has driven the probability up or down enough) but the change of location itself will be instantaneous.

Quantum physics is cool 🙂


%d bloggers like this: