November 91 - Pascal Man Submerges Self in MacApp 3
Pascal Man Submerges Self in MacApp 3
Jesse Feiler
Jesse Feiler knows that Elvis lives-in Michigan-and that he's busy writing MacApp
software. Perhaps any Pascal programmer can reach this level of mental acuity just
by writing a small application in MacApp 3. See for yourself-follow Feiler, prior
Pascal programmer, as he is baptized by total immersion into a new life of C++.
This article relates the travails of a Pascal programmer who learned C++-the why,
the how, and the wherefore. In spite of all the words that have been written and
shouted in the language wars, perhaps this will add something to the conversation and
help those who follow a similar path to MacApp 3.
Into the comfort zone
It took two weeks for me to feel comfortable with the C++ language. That meant being
able to write code that compiled the first time (or the second time), and did what I
expected it to do. That also meant knowing enough about the language's capabilities to
know what constructs were appropriate in various places-even though I had to look up
the syntax for those constructs in the manuals (as I still do in Pascal).
While I was learning C++, a colleague working on the same project was learning both
MacApp and C++ (he knew Pascal). We both felt MacApp was much more important
and difficult to learn. In terms of designing an application, knowing the MacApp
classes and methods provides far more advantage than knowing C++ or Pascal.
Although I will return to these points below, it is important to note two things. First, I
didn't need to learn C++ to program with MacApp 3. Second, I was able to read and
understand MacApp 3 code from the beginning-but only with the assistance of
MacsBug and my prior knowledge of MacApp. If you've ever cuddled up in bed with the
MacApp source code on a cold winter night (yecch!), I'm sure you'll agree that you
could probably understand DoMenuCommand even if it were written in an Urdu
derivative of BASIC.
An assuaged concern
Along the way I learned that C++ is a more disciplined language than C, and many of my
complaints about C are answered in C++. One indication is this section from the MPW
C++ Appendix E: MPW C++ Style Guide:
"It's possible to partially circumvent the strong type checking C++ imposes
on function arguments. You should avoid doing this if at all possible. C++, like
ANSI C, allows you to cling to C's past by declaring functions that take
unspecified numbers and types of arguments, the classic being
Obviously, the sort of undisciplined code I associated with C is discouraged in C++.
Pride and prejudice
I've been programming in Pascal and in its direct antecedent, ALGOL, for over 20
years. I know the language very well. I've programmed, taught it, and designed
systems based around the language and stack based machines.
As a manager, I've also formed a few opinions about languages. I don't present these as
facts, merely as personal prejudices. Here are some of them:
• People who are taught programming using Pascal tend to make better
programmers than people who are taught with other languages. Not
surprising, since Pascal was designed as a teaching language. Pascal-taught
programmers can in general be relied upon to be better programmers no
matter what their ultimate language is-even if it is COBOL.
• C programmers can be sloppy and careless. This prejudice arose from
noticing that C programmers learning Pascal seemed to rebel at Pascal's rigid
type declarations and lack of automatic coercion.
• Good programmers can write good programs in any language.
• Bad programmers can write worse programs in BASIC and C than in other
languages.
• C seemed to have been designed for people who can't type, since strange
symbols seem to substitute for words which I relate to better (like "begin
and "end").
• As sort of a corollary, C is hard to read aloud.
As you may realize from this list, in my own work, I stuck to Pascal. When I
subscribed to ETO, the one piece of the puzzle I had to buy was C++, so I did. I never
installed it, and didn't even look at the documentation. And when it was announced that
MacApp 3 would be written in C++, I didn't feel that the world was coming to an end,
since everyone stressed that we'd still be able to use Pascal for our applications.
Then the language war broke out. As noted in the sidebar accompanying this article,
our language war was a bush-league event. Still, as my kilobyte charges on AppleLink
kept increasing, I began to get more curious.
On the sidelines
Despite the prejudices outlined above, I didn't feel qualified to participate in the
language wars (and even had trouble understanding some of the terms), since I didn't
know C++. I looked at the documentation I had on the shelf, and decided that the several
hundred pages involved were too much of an investment to make at that time. I bought
the two Addison Wesley books-Elements of C++ Macintosh Programming and C++
Programming with MacApp-and browsed through them. Eric Berdahl's articles in
FrameWorks were also very interesting, but I didn't feel that I knew much yet.
Then a new project came up, and I decided to implement it not only with MacApp 3 but
to use C++ as well. I used C++ on this project in order to find out enough about C++
to take a side in the language wars. You don't have to use C++ in order to use MacApp
3. I only learned C++ to find out what the fuss was about.
LEARNING C++
I used the total immersion principle, now commonly used for teaching natural
languages, to learn C++. I didn't worry about the theory or the background. I put
myself in a position where I had to use the language and-most important-where it was
not unreasonable for me to be able to use the language.
While this technique (if you want to dignify it with that term) was an ad hoc,
idiosyncratic approach, some of the things I did may be useful to others. The steps I
took had the virtues of getting me up to speed in two weeks and getting an application
that uses MacApp 3 and C++ into a basic shape in four weeks.
A small, new project