Updates
Latest Tweet
What's New?
Check out for latest innovation, a computer based training video collection
Like this Page
Write Portable Code: An Introduction to Developing Software for Multiple Platforms Review by Ivan Milles
I need this book
Enter Brian Hook's Write Portable Code. Portability is a sort of a holy grail for programmers, and there is no lack of knowledge floating around Usenet and Internet. However, Brian Hook tried to recommend a book on the subject to a friend, and didn't find one. So he set out to write his own.
The result is a tome that should reside on every programmers desk sooner or later. The book's cover pictures a donkey striving uphill, and I can definitely releate to that. Portability is not only a target hard to aquire, but it is also a target roaming about in a minefield. I consider myself a best-practice programmer: stability and portability is important to me. However, while reading this book, I quickly realized that I know nothing. Each and every chapter contained possible gotchas that have eluded me for years. This book does two things: it points out those gotchas, and it gives the reader oodles of clever tricks, background info and solutions. And best of all, those tricks are often of the stablest possible quality.
Diving into this book, I had to break up old ideas about what is safe and not. For can you rely on sizeof(int)? Are you sure main() is your entry point? What if you need to move to a mixed-endian platform? Westwood's assumptions about floating point behaviour made it impossible for Aspyr to implement network play across platforms for Command & Conquer: Generals. Deciding on portability is also a matter of choosing your platforms. Hook points out that you can write a program that runs the same on a clustered super computer as well as a coffee machine, but it doesn't make much sense. Instead, establishing a baseline will go a long way towards keeping your sanity. He does not, however, back down from tricky configurations: there are recommendations and warnings that apply to esoteric platforms, e.g. embedded environments with very limited resources.
Many of the examples in the book are drawn from a cross-platform audio library (SAL) that Brian Hook has written. Seeing the concepts in the book in their actual implementation brings a lot to the table - his treatise points out both goals, possible problems, and solutions.
Since the book is so C++-centric, I would have valued information on the Standard Template Library (STL). While its name promises a standard, it has a few extensions that might not always be around. Performance characteristics also vary across implementations.
Brian Hook has a remarkably clear and readable language. Even though the material in the book is complex, and Hook is writing in a very to-the-point manner, every nuance of the issue gets across. A result of many hours of editing, I'm sure, and those were hours well spent. I finally managed to get the ISO, ANSI, IEEE and many of their different standards sorted out in my head, no small feat for Brian!
Achieving portability is a matter of being extremely cautious, and it is surrounded by many misconceptions and myths. In that regard, Provided that Brian is right (which I'm really not qualified to tell), he becomes a sort of myth-buster. However, since he comes from a background with portability engineering at id Software and 3Dfx, he does have the history to back up his tricks.
The book is very C/C++-centric, but many of the concepts are directly portable to other languages such as (yes) Java. As for the code samples, they are a bit long-winded at times, but always clear. My only gripe is that some of the Mac source code samples aren't always optimal - they are correct and work, but could sometimes have been accomplished in a less complex way. That is, however, mostly a question of form.