Skip to main content

Once upon and Algorithm - Martin Erwig ***

I've been itching to start reading this book for some time, as the premise was so intriguing - to inform the reader about computer science and algorithms using stories as analogies to understand the process.

This is exactly what Martin Erwig does, starting (as the cover suggests) with Hansel and Gretel, and then bringing in Sherlock Holmes (and particularly The Hound of the Baskervilles), Indiana Jones, the song 'Over the Rainbow' (more on that in a moment), Groundhog Day, Back to the Future and Harry Potter.

The idea is to show how some aspect of the story - in the case of Hansel and Gretel, laying a trail of stones/breadcrumbs, then attempting to follow them home - can be seen as a kind of algorithm or computation and gradually adding in computing standards, such as searching, queues and lists, loops, recursion and more.

This really would have been a brilliant book if Erwig had got himself a co-author who knew how to write for the public, but sadly the style is mostly heavy academic, so the cleverness is rather wasted. Sometimes this comes across in labouring points and at others in spending a lot of effort on what is little more than defining labels for things, rather than providing useful information and context for the reader. It's not that there's not a lot of good material in there, just that it's hard work to dig it out, where I'm sure the whole idea of using the stories was to make it more approachable.

Part of the problem is that the stories themselves don't always work very well as an analogy for what's happening in the computation. So, for example, in the section dealing with sorting he comes up with the task of sorting the tasks and places that Indiana Jones needs to deal with to find the Lost Ark. The unsorted list includes the likes of: disc, sunbeam, Marion and Nepal. The algorithm used involves finding the 'smallest' element... which somehow we are supposed to instantly see is Nepal. Using numbers would not have been so well-linked to the story, but at least it would have made some sense to the reader.

Perhaps the low point is the section that uses a part of the song 'Over the Rainbow' (giving us a tenuous story connection to The Wizard of Oz) to examine language and meaning. If you aren't familiar with musical notation, I'm not sure it's a very helpful analogy... and if you are, some of the ways it's used (particular the assertion of what bars are for) doesn't entirely make sense.

I was a professional programmer for a number of years, but without a computer science background. So I was very familiar with how to do this stuff, but knew nothing of the theory behind it. As such, I found the content of the book really interesting - and the story idea should have made it doubly brilliant - but the execution meant that it didn't deliver anywhere near as well as it could have. Even so, there's a lot to savour, and it's definitely worth persevering to get a feel for why computer programs involve far more than just 'cutting code.'


Hardback:  

Kindle:  

Using these links earns us commission at no cost to you

Review by Brian Clegg

Comments

Popular posts from this blog

The Decline and Fall of the Human Empire - Henry Gee ****

In his last book, Henry Gee impressed with his A (Very) Short History of Life on Earth - this time he zooms in on one very specific aspect of life on Earth - humans - and gives us not just a history, but a prediction of the future - our extinction. The book starts with an entertaining prologue, to an extent bemoaning our obsession with dinosaurs, a story that leads, inexorably towards extinction. This is a fate, Gee points out, that will occur for every species, including our own. We then cover three potential stages of the rise and fall of humanity (the book's title is purposely modelled on Gibbon) - Rise, Fall and Escape. Gee's speciality is palaeontology and in the first section he takes us back to explore as much as we can know from the extremely patchy fossil record of the origins of the human family, the genus Homo and the eventual dominance of Homo sapiens , pushing out any remaining members of other closely related species. As we move onto the Fall section, Gee gives ...

Pagans (SF) - James Alistair Henry *****

There's a fascinating sub-genre of science fiction known as alternate history. The idea is that at some point in the past, history diverged from reality, resulting in a different present. Perhaps the most acclaimed of these books is Kingsley Amis's The Alteration , set in a modern England where there had not been a reformation - but James Alistair Henry arguably does even better by giving us a present where Britain is a third world country, still divided between Celts in the west and Saxons in the East. Neither the Normans nor Christianity have any significant impact. In itself this is a clever idea, but what makes it absolutely excellent is mixing in a police procedural murder mystery, where the investigation is being undertaken by a Celtic DI, Drustan, who has to work in London alongside Aedith, a Saxon reeve of equivalent rank, who also happens to be daughter of the Earl of Mercia. While you could argue about a few historical aspects, it's effectively done and has a plot...

Amazing Worlds of Science Fiction and Science Fact: Keith Cooper ****

There's something appealing (for a reader like me) about a book that brings together science fiction and science fact. I had assumed that the 'Amazing Worlds' part of the title suggested a general overview of the interaction between the two, but Keith Cooper is being literal. This is an examination of exoplanets (planets that orbit a different star to the Sun) as pictured in science fiction and in our best current science, bearing in mind this is a field that is still in the early phases of development. It becomes obvious early on that Cooper, who is a science journalist in his day job, knows his stuff on the fiction side as well as the current science. Of course he brings in the well-known TV and movie tropes (we get a huge amount on Star Trek ), not to mention the likes of Dune, but his coverage of written science fiction goes into much wider picture. He also has consulted some well-known contemporary SF writers such as Alastair Reynolds and Paul McAuley, not just scient...