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:  



Review by Brian Clegg

Comments

Popular posts from this blog

The AI Delusion - Gary Smith *****

This is a very important little book ('little' isn't derogatory - it's just quite short and in a small format) - it gets to the heart of the problem with applying artificial intelligence techniques to large amounts of data and thinking that somehow this will result in wisdom.

Gary Smith as an economics professor who teaches statistics, understands numbers and, despite being a self-confessed computer addict, is well aware of the limitations of computer algorithms and big data. What he makes clear here is that we forget at our peril that computers do not understand the data that they process, and as a result are very susceptible to GIGO - garbage in, garbage out. Yet we are increasingly dependent on computer-made decisions coming out of black box algorithms which mine vast quantities of data to find correlations and use these to make predictions. What's wrong with this? We don't know how the algorithms are making their predictions - and the algorithms don't kn…

Infinity in the Palm of your Hand - Marcus Chown *****

A new Marcus Chown book is always a treat - and this is like a box of chocolates: a collection of bite-sized delights as Chown presents us with 50 science facts that are strange and wonderful.

The title is a quote from William Blake's Auguries of Innocence: 'To see a World in a Grain of Sand, / And a Heaven in a Wild Flower, / Hold Infinity in the palm of your hand, / And Eternity in an hour.' It would seem particularly appropriate if this book were read on a mobile phone (so it would be literally in the palm), which could well be true for ebook users, as the short essays make excellent reading for a commute, or at bedtime. I found them distinctly moreish - making it difficult to put the book down as I read just one more. And perhaps another. Oh, and that next one looks really interesting...

Each of the 50 pieces has a title and a short introductory heading, which mostly give a feel for the topic. The very first of these, however, briefly baffled me: 'You are a third mus…

How to Invent Everything - Ryan North ****

Occasionally you read a book and think 'I wish I'd thought of that.' This was my immediate reaction to Ryan North's How to Invent Everything. The central conceit manages to be both funny and inspiring as a framework for writing an 'everything you ever wanted to know about everything (and particularly science)' book.

What How to Invent Everything claims to be is a manual for users of a time machine (from some point in the future). Specifically it's a manual for dealing with the situation of the time machine going wrong and stranding the user in the past. At first it appears that it's going to tell you how to fix the broken time machine - but then admits this is impossible. Since you're stuck in the past, you might as well make the best of your surroundings, so the aim of the rest of the book is to give you the knowledge you need to build your own civilisation from scratch.

We start with a fun flow chart for working out just how far back in time you are…