Thursday, October 19, 2017
Home » Bot Books » Program Like A Pro

Program Like A Pro

Write Great Code: Volume 1: Understanding the Machine

by Randall Hyde

No Starch Press

Modern programming techniques emphasize rapid development (quick time to market), high-level programming languages such as Java, C++, PHP and Perl, and layers of abstraction that isolate programmers from underlying computing hardware. There are many advantages to these techniques: programmers can quickly develop complex applications that have fewer bugs, are easier to maintain and can run on multiple platforms or can be quickly ported. It’s also much easier to learn to program in high-level languages and use operating system services instead of having to worry about the details of a particular hardware platform.

But these advantages come at a cost: modern software applications and operating systems are often bloated and inefficient. This, at least partially, explains why PCs in the 1980s could boot up and run some applications faster than PCs of today despite having hardware hundreds to thousands of times less powerful. There’s no end to this trend in sight. The latest programming languages such as Java and C# further remove programmers from the hardware by defining idealized “virtual” machines, essentially simulations of computers running on real hardware. We can only hope that Moore’s law holds true and PCs can keep getting faster and more powerful to keep up.

So what if you have a computing platform, a robot controller for example, that has limited memory and CPU horsepower, yet has to perform complex tasks? How can you learn to program this platform using memory and CPU efficient techniques? Few modern programming books will help you. Enter Write Great Code, a series of books by Randall Hyde published by No Starch Press. In Volume 1: Understanding the Machine, Hyde explains things that every programmer should know, but that are glossed over or skipped entirely by most recent books on programming: numeric representation, binary arithmetic and operations, memory organization, CPU architecture, and I/O.

While Hyde explains that there can be many different definitions of “Great Code,” his emphasis is clearly on performance and efficiency. He explains how computer hardware works in detail and how simple programming choices can dramatically alter performance. He gives many examples in x86 assembly language and begins to show how compilers generate code from languages such as C/C++ and Pascal. In the second volume of Write Great Code, Hyde goes further and explains how you can “think low-level” for efficiency, yet still obtain good results using high-level languages.

Hyde’s style is clear and concise, with many examples and illustrations. Despite its detailed technical content, I found Understanding the Machine to be a quick and interesting read.

If there’s any fault I can find with this book, it’s Hyde’s focus on the x86 architecture processor and personal computer hardware. While the x86 architecture is the clear leader in personal computers, it trails far behind other processors in the embedded applications space. It is, ironically, programmers in this space who are most likely to make use of the information in Hyde’s book. Still, the concepts are the same or easily translatable, and Write Great Code fills a void in programmers’ arsenals. I highly recommend this book.

Available from Amazon.com for $26.37