# Macintosh C Programming By Example 1991 — source transcripts, page 2

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-macintosh-c-programming-by-example-1991-58b760/2)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### PDF page 12

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-c-programming-by-example-1991-58b760/2#scan-c6a1a1702a8bd2cb531f5f9d9d040e54889f422c79f2ebc08b388650629e2fa8)

Transcribed text:

1:   PROGRAMMING   THE   MACINTOSH   WITH   THINK   C
Pascal   has a reputation as a fine teaching language. Better still for our purposes, it
was the language of choice internally at Apple as the Macintosh was developed. The
data structures that the Toolbox and the operating system expect to deal with are
forms   Pascal   directly understands. Two problems made us avoid   Pascal:   Coding
pointers and handles-two basic types of Macintosh data-is somewhat cumber-
some in   Pascal;   and accessing low-level data such as individual bits is possible only
through Toolbox macros.
Assembly language, of course, lets you access the bits and bytes in memory, but we
ruled it out because creating data and control structures tends to become quite com-
plex. Assembly language has no data structures or structured loops, leaving you to
invent them yourself. And good assembly language code is difficult to read quickly.
That left us with C, the language we have used for most of our programming projects
in the last five years. We feel strongly that C does a better job of showing the control
and manipulation of data structures for Mac programming than any other language
does. The only real drawback to using C is that the Macintosh's native language is
Pascal,   and C data types and calling conventions differ from their   Pascal   counter-
parts. Another drawback is that C lets you do some very stupid things. C is a   laissez-
faire   language:   It   usually lets you do what you want to do as far as assignments and
pointer arithmetic are concerned, but, because it's so lenient about checking for
compatible data types across assignment operations, it will let you do nonsensical
things in your code without much warning or complaint from the compiler.
C assumes that you know what you're doing. This is the   Pascal   aficionado's major
complaint against C, but it's a feature that we enjoy. Be forewarned, though, that
novice C programmers are virtually guaranteed to fall into one of C's traps at some
point early in their careers.   Guard against C's traps by double-checking every
change you make to a program and by constantly double-checking your data types.
As a prospective Mac C programmer, you need to be familiar with the syntax and se-
mantics of the C programming language. Sure, we'll supply you with working code,
but you 'll need to understand the language if you want to write your own code and
get the most benefit from this book. You'll need to learn the fundamentals of C-
variable declarations, assignments, function definitions, function calls. Don't worry
if you don't have any experience with the language-we'll meet you halfway. Chap-
ter 3 is a brief C primer you can use as a reference. We do suggest that you pick up a
copy of Kernighan and Ritchie's   The   C   Programming Language,   published by   Pren-
tice Hall, if you're serious about learning   C.   This classic, known by the blue Con its
cover, was the first book on the language. Recently revised,   K&R   is still our favorite,
despite competition from dozens of other introductory books on   C.
Although the Kernighan and Ritchie book is excellent for learning how to use C, it
doesn't teach you a thing about programming the Mac. As you read along in this
book, we'll alert you to common pitfalls that await the new C programmer of the
Mac, and we'll beef up our efforts when we get to more advanced topics like data
structures, pointers, and dynamic memory allocation-and their relationship to the
Mac.   Of   course, we think the best way to learn a language is by example. In each
5

Reading notes: Text appears to be a book excerpt rather than an advertisement; no primary heading is printed. Page number '5' appears at the end and was not treated as a date.

Printed product names: Think C · Macintosh · Toolbox · Pascal · C

Languages: English

[Original PDF page 12](https://www.vintageapple.net/files/c7db641f67592eb04ccc7096936e797f7d0c0291c1cd9334eba852b3a33c5ca5/Macintosh_C_Programming_By_Example_1991.pdf#page=12)

[Previous transcribed scans](https://www.vintageapple.net/transcripts/media/va-macintosh-c-programming-by-example-1991-58b760/1.md)
