[comp.sys.mac] "C Programming Techniques for the Macintosh" warning!

chuq@Apple.COM (Chuq Von Rospach) (04/13/89)

Here's a cautionary note for people looking for C books. There's a new
edition of "C Programming Techniques for the Macintosh" by Zigurd and Terry
Mednieks (Sams). The new edition has rewritten the material to work with
ResEdit and LightSpeed C instead of Redit and MacC. This makes it (as far as
I know) the first generally available LSC book out there.

Since I've actually been sitting down and seriously trying to do some Mac
programming in LSC the last couple of weeks, the book looked interesting. I
was involved peripherally in the first edition (you'll see my name in the
acknowledgements) and I thought it'd be a good book to hack with.

Unfortunately, the book has some major problems. The primary application it
uses as an example is a Mandelbrot set (in grays, not color...). This
application is listed twice: in Chapter 8 as a basic application, and in
chapter 9 including file open/save, printing and a few extra goodies. 

I spent a day typing in all 1200 lines of code from the first example. After
a couple of days of tracking down the various obligatory typos from that
much brute-force typing, I found that the program was still buggy -- to the
point of bombing the mac out from under the LSC source level debugger. Not
nice. Since I was pretty sure that I got all of *my* typos, I started
looking for other bugs. 

I found them. Lots of them. By comparing the same routines in the Chapter 8
and Chapter 9 sources, I found about 30 different bugs or significant
revisions -- even though the program in chapter 8 is only supposed to be a
subset of the full program. Many of the bugs are exceptionally stupid,
sloppy ones (using resedit to create a dialog box with visible turned off,
which causes the dialog to go bang when you try to use it; another was
mixing up the window resize procedures so that when you resize a window
vertically, you turn on the horizontal scrollbar and vice-versa!). The
*only* thing I can think of is that when the book got laid out they
accidentally used an obsolete version of the code for that listing. It's
pretty worthless -- although, fortunately, the (mostly) corrected source is
available in chapter 9 [which actually makes me wonder why they wasted the
pages printing the same stuff twice, but that's another issue....].

There are other problems with the book. The design of the mandelbrot
calculation doesn't allow for giving time to the system -- so things like
menubar clocks or Desk Accessories don't get any resources unless you toss
an event at the system, since SystemTask() is only called in the event loop.
The book was written for pre-LSC 3.0, so there's no discussion of the
source-level debugger or any of the new features. The resource generation is
shown by Resedit screendumps, but some of them are wrong and they don't
explain how to use ResEdit -- if you don't know going in, you're going to be
totally confused.

All in all, this edition is significantly MORE buggy than the first edition
and less useful for everyone -- even though it's been converted to a
compiler that is still in production, you would have been better off with
the old book and making the changes yourself -- the first book, at least,
wasn't buggy like this.

The bottom line is this: if you're looking for a C book, look somewhere
else. There *is* an LSC book due out any minute -- one that is supposed to
cover release 3.0 -- and you're much better off waiting for it or buying the
Takasuka book and figuring out the differences between MacC and LSC. This
book has so many problems it's not worth trying to fix. Maybe if they come
out with a new-new edition with unbuggy code, but not in the current format.









Chuq Von Rospach       -*-      Editor,OtherRealms      -*-      Member SFWA
chuq@apple.com  -*-  CI$: 73317,635  -*-  Delphi: CHUQ  -*-  Applelink: CHUQ
      [This is myself speaking. No company can control my thoughts.]

USENET: N. A self-replicating phage engineered by the phone company to cause
computers to spend large amounts of their owners budget on modem charges.