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

Meet the Neighbors - Steven Benner *****

I love popular science books, but it's a quiet sort of love: it's not often a book like this gets me really excited - but Meet the Neighbours (sorry, I know it's Neighbors, but it grates) does just that.  Once upon a time there was quite a market in books speculating about life on Mars, but of late most Martian titles have focused on getting to and colonising Mars (though often avoiding the 'c' word). Steven Benner drags us back to see the evidence for life having existed there, and does so with a vengeance. (Almost literally - he really lays into those who are dismissive of what evidence there is.) Do we have proof? Well, no - but proofs are for mathematicians. As Benner says 'science does not deal in proof... Rather, it relies on a 'preponderance of evidence' standard to shift the burden of proof.' Benner points out the weird reality that since the Viking landers, which arrived in the 1970s, there hasn't been a mission looking for organic sig...

Data Empire - Roopika Risam ****

The central thesis presented by Roopika Risam is that information gives us (and particularly countries) the power to organise, control and dominate others. Although I have a couple of issues with the presentation, this is a genuinely interesting trip through the history of our use of stored information from the earliest tallies to the latest information technology. I loved a quote from Lisa Gitelman that data is is always 'cooked' so 'raw data is an oxymoron'. This neatly underlines Risam's thesis that data and information are not neutral facts, but rather tools that (like everything from fire to electronics) can be used for good or evil. As we are taken through the historical context, it can sometimes be a little difficult to judge whether Risam regards a particular example as bad or good, even when the outcome is disastrous. One thing I didn't like too much is the adherence to a popular science writing approach that has got distinctly hackneyed: opening chapte...

Andrew Jaffe - Five way interview

Andrew Jaffe is professor of astrophysics and cosmology at Imperial College, London and director of the Imperial Centre for Inference and Cosmology. His new book is The Random Universe. Why science? I’ve always been interested in science, in particular in  astronomy, astrophysics, and space. One of my earliest memories - back in nursery school in New Jersey, I think - was watching one of the moon launches. I wanted that excitement to be part of my life! I never got to be an astronaut, but I did get to be part of the Planck Satellite team, and was privileged to be able to travel to the ESA Spaceport in French Guiana to watch the launch.  In between, I was lucky enough to have a supportive family, get a good education, and find inspiring teachers, mentors, and collaborators. They helped me model the universe, and helped me learn how to refine those models in the face of experimental and observational evidence. That is, they taught me to be a scientist. Why this book? The Random...