eBlue, Sacra Blue Online Magazine
Nov 2001 — Issue 232
eBlue articles
Evelyn Kaehler
HardCopy

Edited by
Evelyn Kaehler




Contact Information:
Evelyn Kaehler

Three Books for Programmers

Tricks of the Windows Game Programming Gurus
Reviewed by Tim Feldman

Sigh. Maybe you learned this old lesson from your mother when you were young: "If you can't say anything nice, don't say anything at all." Reviewing this book reminded me of that saying. Since I'm trying to do a service to potential buyers, I feel obligated to point out the problems with the book. Sorry, Mom. I'll also try to say something good about it. Here goes!

It's Not 3D
This book has a number of serious problems. One of the biggest problems is that it actually doesn't cover 3D programming, despite its title. It deals with 2D programming, but 3D is a much bigger subject, and this book doesn't touch it. In the introduction, Mr. LaMothe says: "...when you're done with this book you will be able to create a full 3D, texture-mapped, professionally lit video game..." Well, none of that is true. It's a 2D book, period.

Now, if you're an experienced game or graphics programmer, you can tell at a glance that it's not about 3D programming, so you won't be fooled (and you probably wouldn't need this book anyway). But if you're a beginner you won't necessarily realize that the book is limited to 2D; the cover will fool you. And the book is indeed aimed at beginners, as its introduction and back cover state. For shame.

One of the book's CDs contains some material on 3D programming and on Direct3D from other authors, but that material is not integrated into the text at all, and some of it is of pretty poor quality. It's not really part of the book at all; it's filler material for the CD.

How does Mr. LaMothe explain this lack of 3D? Well, at the end of the book's text he appends an epilogue that says that 3D will be covered in Volume II... in other words, in some other book that he will write in the future! But you can't tell from looking at it that this volume is the first in a planned series.

So what is the book really about? It's merely an introduction to 2D graphics and simple game programming, using Microsoft's Visual C++ and the DirectX APIs. (You can, incidentally, use its source code with other C++ compilers, such as Borland's excellent C++ Builder, if you are an experienced C++ programmer.) It is quite definitely a tutorial text intended for beginners; and it is quite definitely not an extensive compilation of tricks used by professional programmers.

Pointless Windows Tricks
The next thing that struck me as odd, is that Mr. LaMothe devoted the first two hundred or so pages of the book to the subject of programming using the general Windows APIs. But the remainder of the book's one thousand pages are about programming with DirectX, which is very different from the general Windows APIs.

Of course, you need a small Windows framework in order to work with DirectX, and he provides that, but it was scarcely necessary to spend twenty percent of the book detailing Windows programming techniques that you won't be using much. Once you include his basic framework, you can ignore the Windows APIs and concentrate on DirectX, gameplay, designing computerized opponents, and so on.

Because of this strange section on the Windows API, and the lack of the 3D material, I got the strong impression that Mr. LaMothe simply sat down and started writing, without planning what he was going to write about.

A...Strong...Writing Style
Maybe it's easy for Mr. LaMothe to write "off-the-cuff"; that might explain the major flaws that I've mentioned so far. He certainly has a loose writing style. At first it is refreshing: he writes directly to the reader; it's not like a textbook at all. But after a few chapters, his style starts to wear. He is very brash, and almost juvenile at times. When I ran into an actual obscenity in his source code on one of the CDs, his writing style lost any attraction that it had for me.

Just Enough to Get Into Trouble
The book serves as an introduction to 2D graphics and game programming, but that's a very big subject. This book can't cover it all; no one book could. Professional graphics and game programmers have bookshelves crammed with articles, textbooks, magazines, CDs, and conference proceedings about their field; they can never get enough information, explanations, or examples. I think that Mr. LaMothe's book doesn't adequately convey this tip-of-the-iceberg situation; beginners will need far more than this one book to become proficient at the art.

The Good Things to Say
Given those negative comments, can I still redeem myself in my mom's eyes by saying anything good about Mr. LaMothe's book? Well, yes, if I try hard.

It does teach at least some basic ideas about 2D graphics and game programming: fundamental ideas such as rasterizing lines, clipping and filling polygons, and so on. None of it is ground-shaking stuff; it's what you'd find in any introductory text in this field, and so I can hardly think of it as a set of "tricks" by "gurus."

It does contain a working framework for 2D graphics games, with source code and quite a few simple example programs. The final chapter of the book puts forth an Asteroids-type 2D space shooter game. You can find plenty of other game programming examples on the Web or in other textbooks, however.

It does explain a lot of Microsoft's DirectX game programming APIs, from an introductory viewpoint. So do a lot of other textbooks, of course; DirectX has always been a hot subject.

It contains two CDs of material (not one CD, as the cover and text imply; apparently, the publisher decided late in the project to include more material than would easily fit on one CD). In addition to the source code for the book, the CDs contain a hodgepodge of demos, artwork, sound files, utility programs, articles, papers, and online books about 2D and 3D graphics, game programming, and more-or-less-related material. There's even a "bonus chapter" about writing text-based games. This CD material is of varying relevance and quality.

Also included are the Microsoft DirectX SDK (version 6.1), and a second CD containing an introductory version (6.0) of Microsoft's Visual C++. You could get both of these in other textbooks, of course; Microsoft has distributed them through a number of publishers, and the DirectX SDK is free to download.

Finally, there are a few good short "tricks" for graphics and games programmers, hidden in the book in sidebars. Sadly, there aren't many of them, despite the book's title; it's just another letdown in this disappointing book.

My mom doesn't usually read the reviews that I write—programming is not her cup of tea—and maybe that's a good thing in this case, because I couldn't find many nice things to say about Tricks of the Windows Programming Gurus.

Tricks of the Windows Game Programming Gurus
by Andre LaMothe
Sams Publishing, 1999
ISBN 0-672-31361-8
1040 pages, +2 CD's, $49.99

GNU C++ for Linux (Professional Developer's Guide)
Reviewed by Tim Feldman

Appearances:
At first, this book confused me. Its title implies that it is about the GNU version of C++, as used for Linux programming, but it devotes only a few pages to a discussion of the many options and settings of the GNU C++ compiler; it's certainly not a book about guru-level tricks that you can do with that excellent tool.

Moreover, the book devotes five chapters to the X graphical programming environment, and while C++ certainly is part of X programming, the effort of learning the X system tends to divert your attention from learning about C++. Finally, the book's cover says that it is intended for intermediate audiences—yet much of the book's material is quite introductory, such as its chapters on the basics of the C and C++ languages, or its instructions on installing the version of Linux that is included on the book's CD.

Other parts of the book, such as the chapters on the Standard Template Library, deal with material normally considered to be advanced topics.

So: What is this book really about? Is it worth reading? And if so, who should read it? Let's dig into its 800-odd pages and see if we can clear up the confusion.

Basics of C++
The book starts with several chapters on installing Linux and the GNU C++ compiler collection and tools. If you don't have a Linux system, you can install Mandrake's Linux distribution from the book's CD. That will install the compiler system as well. If you already have Linux up and running, it almost certainly already has the compiler installed, and all you'll need to do is load the book's source code from the CD.

Once you're ready to run the GNU compiler, Mr. Swan spends about 18 chapters on teaching you C++ programming from the ground up, starting with the usual simple "Hello world!" level of programming. He covers most of the C++ programming language in a fairly standard way, using little code snippets to teach a point, sometimes combining them into C++ classes, and using them in short test programs.

It's a common textbook approach to teaching, and it's not particularly engrossing. After a while, the entire little demo programs with characters named "c", strings named "aaaa", and integers named "number" tend to blur together in your mind, and your learning efficiency goes way down. It takes a very creative writer to present this basic material in a dynamic and engaging manner; sadly, Mr. Swan wasn't able to pull off that trick.

Class Libraries, X and V
Once he's covered the basics of C++, Mr. Swan tackles C++ class libraries in six chapters that introduce the Standard Template Library, the X programming environment, and the Xlib library.

The Standard Template Library ("STL") is a set of C++ container template classes. It's a fairly advanced part of C++ programming; the idea is to have a set of standard algorithms for working with data structures, designed and implemented such that you don't have to rewrite the algorithms to work with new kinds of data structures. Mr. Swan devotes three chapters to the STL, introducing its data structures and algorithms. Again, he uses code snippets and very short demo programs; programmers wanting to see the STL used in significant, "real-world" applications will have to look elsewhere to get their feet very wet.

It's the same story with the book's handling of the X system; the examples are all fairly trivial. Since X is a graphical environment, the examples are perhaps a little more visually interesting than the text-based examples, but they are still very short and extremely basic. For example, one of the most advanced programs lets you use the mouse to draw or erase black and white lines.

The final chapters of the book deal with "V," a cross-platform API that lets you compile X programs to run under Linux, Windows, or OS/2. Mr. Swan says that he "stumbled across" V and realized that it would greatly reduce the complexity of developing actual X applications, which he says might otherwise seem to be "an impossible task."

I thought that was an odd assertion, given the large number of successful X applications that have been written without V, so I was eager to see just how easily Mr. Swan could write a non-trivial V application. Unfortunately, I still don't know that and I can't really say how good V is, because Mr. Swan's V examples are still quite basic; the most complex one is another mouse line-drawing program. He also doesn't compare a Linux V program with a Windows or OS/2 version of the same application; that would have been an interesting, useful and obvious exercise.

Style, Impressions and Audience
As I've already mentioned, the examples in the book aren't particularly catchy. Neither is Mr. Swan's writing style. It's fairly dull, actually; or perhaps "tired" is a better word. I had professors like that in college; they had taught their subjects for many years. Rather than polishing their presentations to a refined smoothness, or rising to the challenge of finding fresh material for each year's class, those professors merely repeated their earlier lectures.

The years of repetition dulled their presentations. I'm reminded of one very senior professor teaching a graduate class in image processing algorithms. It was a warm spring afternoon, and we were all sitting quietly while he droned on. Suddenly he stopped writing a long derivation on the blackboard, and he peered back at us over his shoulder. "I'm doing this on auto-pilot, you know," he announced solemnly, "so if you have any questions, you'd better speak up now, before we move on." Such motivation! Such dedication to instilling a love for his subject matter in his students!

I'm afraid that reading Mr. Swan's book made me think of that professor more than once. The end of the book is a good example: He finishes discussing the V library rather abruptly, and, as if he has reached some unseen but inflexible limit on the amount that he may write, he actually says "...this book has to end at some place, and, I suppose, this place is as good as any."

The only place where he shows much more personality, he is actually rather irritating. It's in the preface to the book, where he rambles on about how bored he was, writing book after book, page after page, for more than twenty years—while floating on his sailboat in the Bahamas, fishing.

He reveals that he got the idea for writing this book after a hearty meal, when he settled in to read a few books on Linux that he had brought along. Apparently, he got very excited after he installed Linux on his laptop and fired up the GNU C++ compiler for the first time, and that motivated him to overcome his weariness and write yet another book.

Frankly, it doesn't seem that it was worth his effort. The impression that this book leaves with me is that Mr. Swan saw an opportunity to sell another large programming book—this one aimed, more or less, at programmers new to C++ and Linux.

There doesn't seem to have been a much stronger motivation than that. His book suffers from a mediocre writing style, dull examples, and a wide variability in difficulty level, and it doesn't delve deeply into Linux programming topics, restricting itself to a fairly basic introduction to programming with X. The STL material isn't particularly related to Linux at all.

His intended audience, I think, would be better off spending their money buying a couple of more focused, and better written, books about C++ and Linux.

GNU C++ for Linux (Professional Developer's Guide)
by Tom Swan
QUE Corporation, 1999
ISBN 0-7897-2153-8
848 pages, +CD, $49.99

Linux Programming by Example
Reviewed by Tim Feldman

Here's a competent little book aimed squarely at the DOS or Windows programmer who needs to write a Linux program, but has never worked with all those "big time" Unix-like features such as semaphores, forks, shared memory, pipes, daemons, and ncurses.

Really, I shouldn't call the book "little"; it's about 500 pages long. That used to be a big programming book: my tattered first edition of Kernighan and Ritchie's famous "The C Programming Language" is a slim 228 pages. But the trend nowadays is for massive volumes of at least 1000 pages, packed with a CD or two of source code, demos, and utilities. Mr. Wall manages to cover his material quite well in a much more manageable package, and that speaks well for his writing ability.

Mr. Wall's writing style is quiet and concise. He writes in a fairly neutral tone, addressing the reader directly, but he doesn't try to put too much humor into his writing. He gives plenty of good advice, whether it's about specific details of some library function, or how to design a program to avoid maintenance headaches in the future. In short, his writing, while technical, is clear and easy to read, and his content is worth reading.

Basic Tools
Aimed at the intermediate to advanced C programmer new to Linux, the book starts off with clear explanations of how to use the defacto Linux programming tools: the GNU C compiler ("gcc") and GNU "make," the program maintenance tool. These are command-line tools: no fancy IDEs like those for Windows programming! Mr. Wall does a good basic job of explaining how to use the tools, and he does not succumb to the temptation of regurgitating the tool documentation to pad the book.

At the end of each chapter, he includes a nice paragraph about "What's Next?", where he reviews the chapter's subjects and prepares you for the next chapter. I found these little summaries to be a good way to find my way around the book; they give a different view than either of the book's two tables of contents. It is a qualitative or subjective view rather than a quantitative or objective view. For example, at the end of chapter two, "What's Next?" tells you that you have enough of a foundation in using the tools that you can now begin writing real Linux programs.

Solid Linux Programming
In the next fifteen chapters, Mr. Wall introduces those programming techniques and libraries that make Linux (and Unix) so different from DOS and Windows. In the days when Unix reigned supreme for "serious" C programming, finding clear explanations and examples of these subjects was quite difficult. Typically, you would pore over the library documentation from AT&T or Sun, hacking up their short example programs and pestering any other programmers that you could find who had already puzzled out the subject.

Now that Linux is freely available for the PC, all that has changed: programming "system calls" and "daemons" is no longer supposed to be a power trip for gurus only. Mr. Wall covers the subjects in a clean manner, with plenty of short examples. All of the source is in the book, or you can download it from QUE Publishing if you search for the book on that site. I find that I benefit from typing in the short examples, rather than merely downloading and compiling them: the time and attention spent in typing them in makes me think about them, and so I learn more from each example.

The example programs aren't anything too exotic: Mr. Wall rightly restricts the book to covering those subjects that are generic to all Linux distributions. He covers text-based application programming using the standard ncurses package, but not graphics programming using the many different GUIs that run on Linux systems. He covers files and inter-process communications, but not specialized topics such as modem programming or hardware control. As he points out, those are advanced subjects that you should be able to pick up from other references once you understand the topics that he covers in this book.

Advanced Tools and a Bigger Example
After four hundred pages, you are ready to learn about some more advanced tools, so Mr. Wall goes on to describe two essential tools for serious programmers: "RCS," the revision control system, and "gdb," the GNU debugger. He also shows you how to distribute your applications in the standard Linux ways, using Linux tools such as "tar," "gzip," and "install," as well as the Red Hat Package Manager, "RPM."

By the end of the book, you've learned the basic methods and tools used in serious Linux programming. Mr. Wall ends with an advanced example to tie it all together. The example is a textual database program to catalog music CDs; it's sufficient to demonstrate many of the subjects in the book. The code takes up 20 KB and the technical points have already been covered in earlier chapters, so you'll probably want to download the code rather than typing it in. You'll also want to download it in order to get the example data and utility programs discussed in chapters 13, 20, and 21.

At the end of the book, Mr. Wall gives some good advice in his final "What's Next?" section: He tells you to go forth and code, because there is really no other way to become a proficient Linux hacker than by practice. I agree with him completely. By using his book, you can get a good basic education in the techniques and tools that you'll need. I'd recommend it to any experienced C programmer who wants to learn about Linux programming.

Linux Programming by Example
by Kurt Wall
QUE Corporation, 1999
ISBN 0-7897-2215-1
560 pages, $24.99

Tim Feldman is a consultant in hardware and software design, custom human input and machine control devices, and computer graphics. He has written a number of professional 2D and 3D software applications for artists and animators, games, and video special effects generation, including two complete 3D rendering engines. He has programmed on many different platforms, including Unix, Linux, Solaris, VxWorks, DOS, Windows, and NT, as well as quite a few "bare metal" embedded computers that had no operating system at all. His company, Electric Algorithms, Inc., has a Web site at Electric-Algorithms. Tim is also the President of the Davis chapter of the Sacramento PC Users Group.

eBlue articles
This page prepared by:

Brian Smither

Copyright © 2001 Sacramento PC Users Group, Inc. All rights reserved.
Read our disclaimer and copyright page for more information.