The magazine reviews
The reviews are, uh, pouring in to Bucknall Central. Actually there have been two very favorable ones published, apart from those on Amazon.com. The first is by Bob Swart, from his website and the UK-BUG's newsletter, and the second by Tom Lisjac, as published in Delphi Informant.
Talking of Amazon, I'd like to respond to and address any negative points in the reviews posted there. It's the only way I have to try and correct any mistakes or misunderstandings. More...
Alas alack, because I write for The Delphi Magazine means that they can't review it because of a possible conflict of interest. Oh well.
Bob Swart's review
This is a book that I've been waiting for for a long time (according to the acknowledgements, Julian has worked on it from April 1999 until February 2001, probably even longer). But it has been worth it, because it's an excellent book about algorithms and data structures implemented in Delphi (and Kylix) - usually version independent.
The book consists of 12 chapters. But even before the first chapter Julian takes on the question of "why a book on Delphi algorithms?" in the introduction. He explains that a number of Computer Science algorithms books are hardly practical, and the practical books are mainly for C, C++, or Java. This is a book about algorithms and data structures using Delphi (for Windows, but also Kylix for Linux), with a lot of focus on practical and useful techniques that make sense.
The first chapter starts by describing what an algorithm is, what algorithm analysis is and the "Big-Oh" notation is all about. Although Big-Oh is valid for a "fantasy machine", he also discusses additional issues like memory, CPU, speed vs. time, and some first Delphi specific tips regarding Long Strings (I learned a very nice technique on page 18 that changed the way I use the built-in Pos function of Delphi). Additional topics in the first chapter include debugging and testing using assertions, coverage analysis and more. Julian presents some good rules now and then, that may be common knowledge to some, but are important to mention explicitly nevertheless.
After the first chapter, which really only set the framework and mindset in a mere 26 pages, the book continues with 11 more chapters, each focused on a specific topic. Chapter 2 covers Arrays, including Dynamic Arrays of course. But also covering related classes, such as TList (an array of pointers) and what has happened with TList as of Delphi 5 to support TObjectList. Julian then designs his own TtdObjectList instead. Other topics are Arrays on Disk (just another name for a file where each line or record has a fixed length). Chapter 3 covers Linked Lists, Stacks and Queues. Like the previous chapter, we won't see an algorithm without a data structure to operate on. We see singly linked lists and doubly linked lists, a discussion on benefits and drawbacks, and then move on to stacks and queues (using linked lists and arrays). Chapter 4 covers searching, and is very much related to chapter 5 which covers sorting. The central point of both searching and sorting is the comparison routine, to compares two items. Sequential search (as an illustration of O(n)) is followed by Binary Search, both in arrays or linked lists (so you really feel the chapters "growing" onto each other). Sorting gets a bit more advanced, with about eight different sorting algorithms - each with their strong and weak points discussed in detail. It sometimes feels like reading Knuth for Delphi, and as Knuth's books, this book should be required reading for any Delphi developer who ever needs to search, sort or do anything with algorithms or data structures (which I think is pretty much every Delphi developer). Chapter 6 is a bit of a funny one, about Randomised Algorithms, which discusses random number generation, the chi-squared test and a number of attempts to write a truly random generator using different methods, as well as testing them using different tests. Might be useful if you don't want to use Random and RandSeed. Chapter 7 is about Hashing and Hash Tables, which is a technique to be able to quickly index a given item in a list (use the generated index to both store and find it quickly). Different hash functions are discussed in detail. Chapter 8 is about Binary Trees - an extension of simple linked lists. We read about creating a binary tree, inserting, deleting, and balancing, and of course searching in binary trees and related trees. Chapter 9 is about Priority Queues and Heapsort, which is an extension of chapter 3 (queues) and chapter 5 (sorting). A Priority Queue is implemented using a Heap (a binary tree with special properties and operations), which logically leads to the Heapsort - in case you wondered. Chapter 10 is about State Machines and Regular Expressions. I must admit that this was the least practical chapter in my view. We learned about finite deterministic state machines, but all I could do was remember the theory from the university I learned two decades ago. Nevertheless, the implementation was sound, although I'm not sure I'll be using it anytime soon. Chapter 11 was right back being practical, covering Data Compression. After we learn the difference between lossy and lossless compression, we continue with a few algorithms such as Minimum Redundancy Compression (Shannon-Fano, Huffman and Splay Tree) and Dictionary Compression using the LZ77 algorithm. The final chapter 12 covers some Advanced Topics, starting with the Win32 specific multithreading algorithms Readers-Writers and Producers-Consumers, as well as finding differences in two files.
Right after chapter 12, you get the epilogue, where Julian is the first to admit that even this book is not complete (where are the B-Trees, Julian), but I can forgive him easily. What follows is the list of references (on the next page), index and CD with full source code of the book as well as Julian's EZDSL freeware library and trial-runs of TurboPower software.
A great plus is that the code in the book works for every version of Delphi and Kylix (and probably also in C++Builder), and I'm fairly confident it will remain working in the next version(s) of Delphi and Kylix to come. A bonus point is the syntax high-lighting in the source code listings. A small effort for the author/publisher, but a great help for the reader who sees the source code for the first time.
The conclusion [of this review] is the same as the start: I have waited a long time for this book, but it has been worth it. If you're only half serious about data structures and algorithms (or efficiency for that matter), then you should read this book. You won't be sorry, trust me!
- Bob Swart
(Copyright (c) Bob Swart, 2001)
(The original can be found here on the DelphiZine site. It was published in the November 2001 issue.)
Shopping for a good technical reference can be a formidable task. And judging them solely by weight, thickness, or number of pages is a great way to take home an expensive doorstop. Once in a while, however, an obvious and easy pick comes along; Julian Bucknall's The Tomes of Delphi: Algorithms and Data Structures is one such find.
The book provides an "all Delphi, all the time" perspective to a wide variety of classic topics. If you're thinking that this theme sounds old, conventional, and potentially boring, don't be misled - the presentation in this book is anything but ordinary.
While some classical texts do tend to be stodgy, Julian Bucknall makes building B-trees, hash algorithms, and linked lists seem like high adventure. Topic development is clear, consistent, and engaging where each paragraph draws you into the next. Once opened, this book is difficult to put down.
There are 12 chapters and 500+ pages covering arrays, lists, searching and sorting, random number generation, hashing, B-trees, queues, state machines, regular expressions, and a very interesting chapter on data compression. While there's just enough history and theory presented to thoroughly ground each topic, the dominant focus of the book is the building of optimized and practical implementations in Delphi.
The book targets an "Advanced" audience, but don't pass it by if you're a Delphi beginner with a basic understanding of OOP. Classical algorithms and data structures are a perfect place to begin building a solid foundation in any programming language. Getting to the next level is always a stretch, but the entertaining and well ordered presentation coupled with the cleanly written examples in this book can be a big help on the path to the intermediate and advanced ranks.
The CD contains the book sources, the author's EZDSL freeware library, and a commercial trialware package. Open any of the source files and you'll find optimally written and lavishly commented code. There's not a component to be found as the library routines are a collection of classes - ideal for building reference implementations and tutorials.
This "lean and mean" approach left something to be desired, however, when it came to the demos, which were packaged mostly as console applications. While DOS-like demos were fine in the days of Turbo Pascal, a top-level GUI would have provided far better support for the Delphi-centric theme of this book. A form and graphical controls would have also worked better with Kylix where the IDE doesn't spawn console apps into a separate shell like Delphi does under Windows. Since I had Kylix configured to start without a command shell, the demos didn't have access to standard I/O and appeared to hang as they waited for keystrokes that couldn't be entered. This was annoying but easily fixed by running startkylix from the command line of an XTerm.
The demos compiled and ran fine under Win32. There were a few minor cosmetic issues under Kylix, and one of the demos couldn't be compiled on either platform due to a missing file on the CD. A note to Julian brought an immediate response and an update to the book's support Web site.
Virtually all of the classical topics in this book have been covered in other books, magazines, and Usenet threads. So why pay $59.95 for information that you can get at the library, download, or cull out of old magazines? Because this book puts it all together, and does so with mastery and a lively presentation. The Tomes of Delphi: Algorithms and Data Structures is a practical, well written, and comprehensive resource. I'm glad it's on my shelf - next to the space where I hope to put Volume 2!
- Tom Lisjac
(Copyright (c) Informant Communications Group, Inc, 2001)