Deciduous Teeth – Skeleton view – Gray's Anatomy

Elegance, Katana and Baby Teeth

Deciduous Teeth – Skeleton view –  Gray's Anatomy

Coders always strive for elegance; while the concept is quite elusive, there are a lot of physical objects whose design is elegant: watches, or katana swords. Yet, very often, once a program is finished the result is not elegant at all, but some contorted abomination. Many are quick to point out that this lack of elegance is the result of the coder’s shortcomings, they are probably using the wrong language, or the wrong paradigm, or wear the wrong type of t-shirts.

Designing programs that are as elegant as a watch is easy, as long as the program has a very well defined specification and is easy to deploy. Deploying a new watch is very easy: you give it to the user, she might have two watches or no watch for a short amount of time, but that is all right.

Things get complicated when you have deploy something over a running system, while some gods just whip up their world in seven days, when time comes to patch, things get complicated, you need prophets, large boats, weird weather, and you realise at the end of the migration that the unicorn did not make it.

Even mother nature has trouble coming up with elegant design when a new system needs to be deployed over an existing one. Take for instance the human version of knifes: teeth. The problem is simple: a new set of teeth needs to grown and deployed while the existing set of baby teeth is still being used. As the picture shows, the process is a hack: the new ones are grown wherever there is space, and there is not a lot of space. The old teeth cannot simply fall out and the new one grow in the space because the kid has to eat the whole time. If this picture does not convince you that the process is scary, there is a much more impressive one on flickr.

Most large scale system have the same problem: they are not started in-nihilo, but need to be deployed over an existing system, while both are running at the same time and sharing some of the resources (time, space, energy, users), then, things get complicated.

Inside of the Kestrel spaceship


Inside of the Kestrel spaceship

Despite what the name suggests, Good Old Games does not only have old games from 15 years ago. Yesterday I bought the game FTL for $7.49. FTL was released this year and is an interesting mix of gaming concepts: you control a ship and her crew and try to bring it as far as possible in front of a wave of invaders. Ship control are extremely simple: you can select where energy is allocated, and on what part of the enemy ships you systems fire. The crew moves in a zelda fashion in the ships, manning stations (providing bonuses), fixing systems and fighting intruders. Each solar system has an event, which is described in plain text, sometimes ambushes, sometimes exploration opportunities, sometimes trading posts. The goal of the game is to collect scrap, fuel and ammunition to make it as far as possible, which is far from trivial, the game is quite challenging for me in easy mode.

The graphics of FTL are interesting: a mix of old school pixel sprites for the characters, simple low depth views of the shop, and gorgeous deep colour background images. The sound-track is quite nice.

All in all this game managed for me to capture the spirit of or , with games that last half an hour, not half a lifetime. If you liked those games, FTL is worth checking out.

HTML5 for old-school coders

HTML has gone a long way since it was just a page description language, served either from static files or a CGI script. Still a lot of software engineers use it in exactly that way, disregarding most of the recent changes in the language and sticking to a minimal set of features. This makes a lot of sense when building simple tools: by only relying on the basics, one is sure to have something that runs fine on every device, be it the lynx browser or a weakly powered phone.

Version 5 of HTML is now becoming quite stable, and the good news is, there are quite a few features that can be used when doing minimal web-interfaces, feature that do not require any javascript, and who fail gracefully in older browsers.

New form input types
Forms now support new input types: email, url, search, number and range. These will fallback to input type text on older browsers, but on newer ones, in particular on mobile phones and tablet, these will display different, specialised inputs. For some types (number in particular) desktop clients also do additional checks, for instance that the number falls within a specified range.
Placeholder attribute
Input control in forms now support a placeholder attribute which adds a greyed placeholder in the form, a good way to give an example to the user. Older browser will just ignore this attribute.
Quick Example

This is boring stuff that should be hidden away by default

Details & summary
HTML5 provides tags that let you collapse some part of the page that contains details, to only show the summary. Just enclose the whole block of text in the details tag and the summary in the summary tag. Older browsers will just ignore both, while newer-ones will display a collapse widget.

Meter 50%
Progress 50%
Meter and Progress
Do you want to display some gauge or some progress bar? There are tags for this. You specify the min, max and the value attribute, and put the fallback display text within the open and closing tags. Older browsers will show the fallback text (say 50%) while the newer ones display the gauge or progress bar. Note that those attributes (min and max) are also supported by the number and range input mentioned above.

Of course, there is a lot more involved in HTML5, but if you just do old-style HTML coding, these are the ones you can use without thinking about Javascript or complex document description.

Screen Capture of the Game Master of Orion II showing an Elerian spy returning a stolen technology: Neutronium Armor

Master of Orion II: Battle at Antares

Screen Capture of the Game Master of Orion II showing an Elerian spy returning a stolen technology: Neutronium Armor

A mentioned a few weeks back that had released a Mac OS X port of Dungeon Keeper, they have now released , a game from , which was one my favourite games of the time. I already mentioned an iOS clone: Starbase Orion, but this is the original game in its VGA colour glory. The big irony is that there was a Mac OS port, but what is running on my current Mac is not based on that codebase, instead it runs the DOS version within an emulator (DOS-Box), as with Dungeon Keeper the game is neatly packaged as a single, 352.4 MB Mac OS X bundle, with everything included. I bought the bundle that also includes Master of Orion 1 and the soundtrack for $5.99, but it seems it is now sold for $2.99.

In Master of Orion II, you control one species that races to take control of the galaxy. While the species are pretty cliché, the game is interesting because there are multiple modes of interactions with the other species, warfare, spying, cooperation. You can also win the game in multiple ways: total domination, get yourself elected in the galaxy council, or defeat the mysterious people from antares – the annoying guys that randomly pillage your systems and destroy your planets. One interesting aspect of the game is the technology tree, where you can only research one branch, so you typically have to somehow get the other branches, either by trade, spying, or conquest.

Another rich aspect of the game is ship design: different technologies give you different options, which let you design different ships, which in turn let you use different tactics in spatial combat. Sometimes your goal is just to destroy the enemy ships, but sometimes capture is more important, either to get ships for free, or to scrap them and recover the technology they contain.

I mostly playing in windowed mode, and did not try out the network mode. The game is fluid and game play was without issues, I found the music playback choppy at times, but I typically turn it off anyway, so this was not a real issue, in-game sounds work fine. Generally speaking the game feels much faster than on a 486 machine, in particular turn computation. Animations are also much faster, although this means they sometimes look a bit jerky.

All in all, this is a really good port of an excellent game, and I really recommend it to anybody who likes turn-based strategy games.

Blue metallic box of Twinings classical Lady Grey Tea

Trade Numbers

Blue metallic box of Twinings classical Lady Grey Tea

Global Trade Item Numbers (GTINs) are in many ways similar to IP addresses, they are everywhere but rarely understood, they also share other properties:

  • They are supposedly unique
  • They are allocated by one organisation using a hierarchical, country based structure
  • There are a few ranges of numbers that have special meanings

The wikipedia entry on GTIN gives a reasonable overview: a 13 or 14 digit long number with a checksum in the last number and with prefixes allocated to various countries, which in turn hand out number blocks to various manufacturers.

So for instance the box of earl grey tea in my kitchen has code 070177086671, you can see the barcode on the right side of the box in the picture. The final 1 in the number is a check digit computed by combining the other numbers. The number is allocated in the US country block (060 – 139), and according to the GS1 database the block starting with prefix 0070177 is allocated to

R. Twining and Company Limited
South Way Andover
SP10 5AQ Hampshire
United Kingdom

According to the box, the tea has been blended and packed in Poland, where the actual tea comes from is, of course, a mystery.

Things get interesting when one looks into the special ranges. The most well known GTIN special prefixes are probably the bookland prefixes: 978, 979, those are used to map 10 digit ISBN numbers into GTIN, this is done by removing the ISBN 11-based check number (the last number or letter X) add 978 and compute the GTIN check number and add it to the end. This is why, nowadays, many books sport two ISBN: one 10 digit long one and one 13 digit long one. Within the ISBN itself, there is again a region prefix, which contains editor prefixes. So for instance my old Hitch Hiker’s Guide to the Galaxy has ISBN 0-330-25864-8, and GTIN 9-780330-258647. So we have bookland (978) language area: english speaking (0) publisher: Pan Books (330) and the actual book identifier (25864).

Another special case is the 03 prefix, which maps the US National Drug Code (NDC) into GTIN. The following 9 numbers are NDC drug code. Here again, there is a manufacturer prefix, followed by a product identifier, but also some numbers used to distinguish the same drug, in different quantities. Note that various countries have similar mappings, for instance, swiss drugs will have a code with the 76 (Switzerland) 80 (drugs) followed by the swissmedic drug code (5 digits) and packaging size (3 digits).

Another special range is the common currency coupon range (981-983), this contains not real product, but reduction coupons. Prefix 982 is for reductions in 1¢ increments, from 1¢ to 9.99€, Prefix 981 is for reductions in 10¢ increments, from 10¢ to 99.9€. The prefix is once again followed by an issuer number (4 digits), followed by an coupon number (2 digits), followed by the value of the coupon (3 digits), where the value 0 means the object is free.

Yet Another special range is the one with prefix 2, this is called the GS1 restricted circulation number within a geographic region, basically those are numbers that are only valid locally, typically one organisation, so for instance the pack of leek I bought at Coop has the code 2131183003156. This code is not valid globally, in the same way that the ip address is not valid globally. Prefixes 02 and 04 have similar semantics.