April 2012 Archives

Mon Apr 30 20:39:32 EST 2012

American Gods

Despite finishing the previous voyage a while ago, I still haven't got around to writing about the latest book I have read: Neil Gaiman's American Gods.

I'm not quite sure what to make of it. The basic premise of the setting isn't unique; that gods are created by and survive on the worship and sacrifice of their followers. The interesting take on the idea is that as various migrants came to America, they brought their gods with them. In modern times, these gods and other beings of folklore (leprechauns and djinni, for example) are reduced to living in run-down apartments, driving taxis and living on the streets.

It's a pretty neat idea, but the telling needed some work. There are a number of short interludes that don't really go anywhere. The main character doesn't really have any impact on anything throughout the story. Things happen to him and around him, but he doesn't seem to do anything. The unfolding of the main plot up to the big reveal is decent, but I just think it could have been told better.

Would I suggest you read it? Sure, but probably put it halfway down the stack, below all the things you promised to read but haven't quite got around to yet.


Posted by Jack Kelly | Permanent link | File under: readings

Sun Apr 8 22:08:26 EST 2012

Captain Hornblower R.N.: Hornblower and the 'Atropos', The Happy Return, A Ship of the Line

Well, I suppose this was inevitable. I found a three-story collection of Hornblower novels on a virtual garage sale.

The Hornblower novels remind me of Ender's Game more than anything else. Hornblower reminds me of Ender Wiggin: both are introspective leaders, isolated by their position. Both are analytical but can understand and manage their underlings extremely well. Both have a habit of pulling surprising victories out of dire situations, as well.

Having constant access to Hornblower's thoughts means you can see how he constructs the persona of a fearless naval captain, despite fighting his fears, controlling his seasickness and maintaining his crew's morale. Unfortunately, most of his thoughts are him berating himself for cowardice, stupidity or some other perceived flaw. The contradiction between his outward success as a leader and his internal self-flagellation is fascinating in small doses but becomes tiresome.

Even so, I enjoyed the three stories: Hornblower salvages British gold from the bottom of a Turkish harbour, sails halfway around the world on orders kept secret from his crew, handles the scheduling of Nelson's funeral and manages to do it all while satisfying his personal morals and his duty to the Royal Navy.


Posted by Jack Kelly | Permanent link | File under: readings

Sat Apr 7 08:13:12 EST 2012

Programming in Prolog

Another programming book. I picked up Clocksin and Mellish's Programming in Prolog after the former second mate encouraged me to learn more about Prolog. Before this, my only exposure to the language was a single lecture at the end of COMP2600 and that old joke ("How many prolog programmers does it take to change a lightbulb? No.").

The first thing that struck me about the book is how honest it is. The authors are very careful to always use the correct terms for everything (predicates, facts and so on) and not hand-wave away things by analogy to more conventional languages.

The main idea behind Prolog is that instead of writing a detailed procedure to compute a result, the programmer needs only to describe the solution and perhaps guide the backtracking algorithm a little bit to keep the search space manageable. An interesting consequence is that the standard library can be a lot smaller. Instead of needing six functions to slice lists six different ways, many of them can be described in terms of "append".

The problem with this is that because of the size of the search space, Prolog has to provide a "cut" operator that commits the search to choices made so far. The trouble with cut is that it can prevent the rules from generating correct (or all of the correct) results when called in reverse. Not only that, but it's not often obvious how a predicate works: it's hard to see which parts will be called forwards and which will be called backwards depending on which way the matcher is trying to instantiate a given rule.

The standard library is also a bit quirky: input and output (as described in the text) can only be done by temporarily redirecting standard input and standard output. Being a bit old, the naming of some of its predicates are a bit odd: files are "consult"ed instead of loaded, input is "see"n instead of read and so on. "assert" isn't used to catch bugs but instead adds new facts and rules to the database.

Even so, Prolog's a pretty elegant language. The basic structure of atoms and functors continues all the way down to the rule definition (:-) and interrogation (?-) operators, and this enables the authors to present a small metacircular evaluator midway through the book.

I'm glad I took the time to learn about Prolog. As a declarative language I've only really seen it lumped alongside make in "lists of languages you should at least read about", but that's a poor comparison. Sure, both are declarative, but their underlying models and methods for determining what work to do are completely different. Even if you grok "make", set aside a few hours to read about Prolog.


Posted by Jack Kelly | Permanent link | File under: readings

Sat Apr 7 07:39:14 EST 2012

The Art of Assembly Language

Randall Hyde's The Art of Assembly Language is one of the works often recommended to new x86 assembly language programmers. It comes in three flavours: two 32-bit versions, one for Windows, one for GNU/Linux and a 16-bit version for DOS. The 32-bit versions use a custom language that adds high-level constructs to assembly language, but the 16-bit version has to deal with DOS. The high-level assembly language in the 32-bit versions put me off, but I was quite happy to read the 16-bit version, being a fan of that crusty old "operating system".

The exhaustive listing of the x86 instruction set (at least, up to the 486) isn't until chapter 6 (mov is introduced in an earlier chapter and the string instructions are postponed until chapter 15). Large chunks of the book are dedicated to the old Microsoft Macro Assembler, MASM. While not very useful as written, mentally translating the examples to nasm is a useful exercise. The final chapters of the book briefly cover how to program various PC hardware: the keyboard, text display, game adapter and serial and parallel ports. There's also a fairly thorough discussion on parameter passing, covering the implementation of several call-by-foo styles of passing arguments.

I would recommend it to anyone who wants to start learning DOS arcana (the BIOS and hardware progragramming chapters might be interesting to hobby-OS developers). The 32-bit versions' "High-Level Assembler" puts me off, so I can't recommend it as a general-purpose assembley language tutorial (for that, I think that one of the other titles here would be more appropriate).


Posted by Jack Kelly | Permanent link | File under: readings

Sat Apr 7 06:54:18 EST 2012

Another Port Davey Voyage

We've just come back from another voyage. This one was ten days at sea, training a new voyage crew from another school. Two crews, actually: we sailed one crew to Port Davey so they could hike from Melaleuca back to civilisation, and we took on another crew of walkers who had walked in.

I have a rule about Port Davey: never trust a hot, still, sunny day. I coined this rule after we dragged anchor in Joe Page Bay last November. That rule proved correct again, when a front came in just as we finished weighing anchor one morning. The wind quickly picked up, sending us all scurrying up the rigging to sea-gasket sail. That was a good experience, as even a few months ago I would not have worked well enough aloft to be useful in such a situation.

The most interesting thing that happened on the trip was the adjustment of daylight savings time. When the shift happened, we were in Port Davey and chose to ignore it. Once we returned to Recherche Bay, we had to come back to the real world. To do that, we extended three watches by 20 minutes each and stepped the clock back one hour after that.


Posted by Jack Kelly | Permanent link | File under: windeward_bound