Write Portable Code - An Introduction to Developing Software for Multiple Platforms (Brian Hook; No Starch Press, 2005)
Moving programs
Brian Hook's guide to writing portable code motivates developers to cross-platform development, and answers many basic questions about code portability. Why not try to make code portable from the beginning? And what should you first do when you need to make a legacy code portable?
So, why write portable code? First of all, you reach a larger market, and avoid locking to a single platform. Also, portable code tends to be more robust, because sloppy assumptions and lazy coding habits tend to reveal themselves.
Moving a program from one platform to another may be a daunting task. Also, platforms themselves evolve. This forces programmers to port their codes even within a single platform. But if you want to remain competitive, you need to use new possibilities such as 64-bit processors.
As Hook discusses in the book, it is a surprise that there are almost no books on portable coding, even though cross-platform development is increasingly common. Software is ported from Linux to Windows, from Windows to Mac OS X, and from desktop systems to pda-type devices, or from desktops to supercomputers.
Hook's book is an excellent introductory review of the subject, although on most topics it covers just the basics. On the other hand, the subject by itself is demanding both in theory and practice, so the reader should know the practice of software development on the intermediate or advanced level.
The book consists of 18 short chapters, and focuses on cross-platform C/C++ development. There are extensive examples of portability issues with C and C++. In addition, scripting languages like Javascript and Python are discussed.
How do you edit your source code on multiple platforms? What about source control systems or portable build systems? It is a bit surprising to see how many different topics affect code portability.
Many aspects of hardware may limit portability, such as byte ordering, address space, and floating point arithmetic. Many compilers have "features" that may pose problems in porting codes.
Writing portable user interfaces poses challenges by itself. Should one use ready-made portable libraries, or code everything from scratch? Also, data portability, file management, and scalable algorithms pose challenges for the programmer.
Hook's approach to porting code is practical. He describes many case examples and concrete tools.
The practicality has a drawback, though. Within a few years many of the examples may not be relevant any more. However, the book is highly useful for a few years from now on.
The writer has personal knowledge about cross-platform development, and also shares his expertise with the readers. The practical advice, clear writing, and a good selection of essential topics make this book a treasure for anyone interested in software development.