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

Six Maths Essentials - Terence Tao *****

This is a book in the 'compact collection of science/maths essays' category beloved of publishers because they can charge hardback prices for fewer than 80 pages of text - but don't let that put you off, because it's excellent. Terence Tao introduces six areas of mathematics: numbers, algebra, geometry, probability, analysis and dynamics. Each of these is descriptive rather than practical (there are only a couple of school-level equations in sight), done in a way that gets to the heart of 'what's the point of this subject' with precision and a good level of storytelling. It's a shame in a way that analysis and dynamics form the final third of the book (apart from a short epilogue), because they don't work as well as the other sections. For the first four, practically everyone will have a vague idea of what they are and what they do - but Tao is then able to open our eyes to their wonders and power. Because Tao has to stay away from any detail of what...

Bradley Efron - Five Way Interview

Bradley Efron is Max Stein Professor emeritus of Statistics and of Biomedical Data Science at Stanford University. He is the inventor of the bootstrap method for assessing statistical accuracy and has published extensively on the theory and practice of data analysis. He has served as president of the American Statistical Association and the Institute of Mathematical Statistics.  A MacArthur fellow, he is a member of the National Academy of Sciences and received the National Medal of Science in 2005. His remarkable contributions to his field were recognized again with the 2018 International Prize in Statistics, which noted his influence on 'statistical thinking in every way, including new pathways in how we communicate and teach statistics to all.' His latest book is To Think Like a Statistician . Why mathematics?   Abstract mathematics and I had an amicable divorce following my Caltech graduation. (I really wasn’t very good at it.) Statistics is a branch of applied mathematics...

Wireheads - Mike Jay *****

This book will particularly appeal to a certain class of person (that certainly includes me) - science fiction fans with an interest in psychology and the history of science/pseudo-science. The subtitle 'an unnatural history of technology in the brain' makes it clear that, though the book is definitely about using technology to influence and access the brain, it's not about medical interventions, but rather the weirder stuff that resides as much in science fiction and the human imagination as anything that is real or practical. Although the book is not about SF per se, it's a constant thread particularly in literature, TV, and film from the mid-sixties onwards and inevitably with a strong link to cyberpunk, which is timely given the Apple TV adaptation of Neuromancer due in 2027. However, there are plenty of surprises in the real world examples from the remarkable story of James Tilly Matthews, encarcerated in Bedlam (the Bethlem Royal Hospital) in the early 1800s who ...