
Pascal at Apple - janvdberg
http://blog.fogus.me/2017/07/20/pascal-at-apple/
======
kabdib
I joined Apple in 1987, about the time they started ditching Pascal in favor
of C. C++ (in the form of CFront) was just starting to be a thing.

Apple's Pascal had been extended to the point where there were few true
differences between it and C, other than

\- strings with busted semantics (size being part of the type being a huge
mistake, leading to a proliferation of types like Str255, Str32, Str31, Str64,
etc). I should add that C's strings were semantically busted, too, and in more
dangerous ways. No way to win :-)

\- nested procedures (not terribly useful in practice, IMHO)

\- an object syntax, used for Object Pascal and MacApp (a complete, though
large and somewhat slow app framework).

\- some miscellany, like enums and modules

Apple extended Pascal pretty extensively, adding pointer arithmetic, address-
of, variant functions calls, and a bunch of things I've forgotten. I could
write some Pascal, then write some C, and squint and they'd look pretty much
the same. Most people shrugged and wrote new code C if they were able, and
then moved to C++ when CFront became usable.

~~~
WalterBright
I liked nested functions in Pascal, and put them in D. They turn out to be
surprisingly useful:

1\. Properly encapsulating their scope, as opposed to having static functions
sit awkwardly somewhere else.

2\. Factoring out common code within the function.

3\. A lot of my need for goto statements vanished with nested functions.

4\. Take the address of a nested function, and it serves as a lambda.

5\. No need to create "Context" structs to pass local data to them.

6\. They replace a lot of what C macros did.

7\. They're inlineable, so are not costly.

I use them more and more as time goes by. It's a pity C doesn't have them,
they'd fit nicely into the language.

~~~
kabdib
Good points, all.

I think I misliked Pascal's nested procedures because they weren't true
lambdas; once the outer procedure returned, the inner procs were no longer
callable (just one contiguous stack, right?). Early-on, using C++ lambdas, I
found myself making the same mistake in a design for some asynchronous
completion stuff. Embarrassing; C++ and Pascal are not
JavaScript/Lisp/Scheme/Smalltalk :-)

~~~
sidegrid
Misliked?

~~~
coldtea
Mind blowing factoid: not everybody on the internet is a native english
speaker.

~~~
kabdib
Not sure what your point is, but it's a real word :-)

------
thought_alarm
I'm reminded of a really great interview with Bill Atkinson where he describes
(among many other things) how he initially brought Pascal to Apple and the
Apple II.

[https://youtu.be/6tUWoy1tJkE?t=45m](https://youtu.be/6tUWoy1tJkE?t=45m)

The Pascal bits are from 45:00 to about 50:00.

    
    
        ...
    
        My manager at the time said, no, we don't want to do this [Pascal],
        people are happy with what they got.  I overrode him and went to
        Jobs, and Jobs said "Well, I'm not convinced. I think our users are
        happy with BASIC and assembly language.  But you seem passionate
        about it.  I'll give you one week to prove me otherwise."  
        
        I was on an airplane within two hours down to UC San Diego and I
        started porting right away.
    
        ...
        
        The other thing that happened then is I had to plug in the disk
        routines, and their system was pretty big and that little 13-sector
        floppy disk didn't have a lot of capacity.  Well, Woz had just come up
        with a different way of encoding the data on the disk so that we could
        get more data for the same disk size, and we needed the 16-sector disk
        routines.  And so Woz came down, and I was there... I had never bothered
        to get a motel because I slept on the bench when I wasn't working.  This
        is in the computer science lab at UC San Diego.  I was busy, I didn't
        have time to go sleep. 
    
        But Woz came down, and I got to interact with him and it was really fun
        because he was working on installing these 16-sector disk driver
        routines, and he'd go 'type type type type type' -- and he didn't type
        in assembly language and have it assembled.  No, he'd type in 6502
        machine code.  Hex. -- He'd type in hex, and then, you know, watching
        him type and he'd go 'type type type' -- pause -- 'type type type type',
        and when he finished I asked him what was the pause?  And he said
        "forward branch, seven instructions, I had to compute the offset before
        I continued".  So, he didn't back-patch the offset, he actually looked
        at what he was going to be typing, knew how many bytes it would take...
        he was brilliant.

~~~
walshemj
Interesting at my first job I did a little bit on USCD Pascal on apple.

~~~
slantyyz
While I did a little bit of COBOL and Fortran (on digital minicomputers) in
high school, USCD Pascal in grade 12 was the thing that really got me off
BASIC on my personal computer (at that time, an Apple ][gs).

IIRC, the line my high school computer science teacher used about USCD Pascal
without paying at the time (around 1988) was that it was out of copyright or
something, but now that I think of it, I'm not so sure that was a legit
reason.

------
rcarmo
I wrote a fair amount of Pascal in my 680x0 Mac days, both in MPW (the
Macintosh Programmer's Workshop) and THINK Pascal. Back then Modula-2 was
available on VAXen and "big" machines, but Pascal was almost "portable" across
Mac/PC/VAXen and was amazingly fast, so it was pretty fun.

I eventually moved to C (also using THINK C - see retrospective link below for
a sample of those heady times) and never looked back until a couple of weeks
ago I set up Lazarus for my kid to play with (there are too many Python GUI
development options, and none halfway as good).

Lazarus is _amazing_ (if somewhat odd in today's world), and I really wish we
had more IDEs like it instead of all the crappy Electron/web approaches for
building desktop apps. It builds fast, tiny, entirely native apps in less than
a second, and is an excellent example of how far Pascal went despite falling
off the mainstream wagon.

(If anyone knows of anything like it for cross-platform desktop apps, let me
know, I'd love to try it out)

\- Link about early C dev on the Mac, that also mentions MPW and Pascal in
passing -
[https://retrocomputing.stackexchange.com/questions/3213/what...](https://retrocomputing.stackexchange.com/questions/3213/what-
was-the-first-c-compiler-for-the-mac)

~~~
vram22
>It builds fast, tiny, entirely native apps in less than a second, and is an
excellent example of how far Pascal went despite falling off the mainstream
wagon.

D meets some of your criteria too, at least somewhat small fast, native apps.
Build speed is decent (or more) too, and it is designed for that - doesn't
have C's repeated overhead of pulling in include files. [1] Haven't tried the
GUI toolkits for D though (yet). There are some, like DLangUI, GtkD, etc. Not
sure if there are any GUI builders like Delphi, Lazarus, VB, Xojo, etc. have.
Also, I think I read that D's language design allows D compilers to be the
single-pass kind.

[1] I think this is the video I had blogged about a while ago, in which Bjarne
Stroustrup talks about the details of that include files issue:

Video: C++, Rust, D and Go: Panel at LangNext '14

[https://jugad2.blogspot.com/2016/08/video-c-rust-d-and-go-
pa...](https://jugad2.blogspot.com/2016/08/video-c-rust-d-and-go-panel-at-
langnext.html)

Edited for wording about D compilers.

~~~
vram22
>doesn't have C's repeated overhead of pulling in include files.

Sorry, typo - I meant to say "C++'s repeated ..."

C may have it too, don't remember if so or not right now.

The video mentioned in my above comment has some details on why this is such
an issue in C++ - from the source, i.e. Stroustrup, the creator of C++.
There's a bit of humor around that fragment of the talk - it is somewhere near
the end, IIRC.

------
cjensen
I really miss Pascal; it was a great and safe language for beginners. As it
was extended with Objects and Modules, it was great for development.

But there are good reasons it was surpassed by C. In early Pascal, you got a
pointer by allocating memory; you could not get a pointer to an existing
variable. You'd be surprised how often that gets in the way when implementing
a data structure. Just _try_ to implement the following function in C without
using the address-of operator:

    
    
      struct list *head = (void *) 0;
      void push_back (struct list *entry) {
          struct list **p = &head;
          while (*p != 0) p = &p->next;
          *p = entry;
      }
    

Pascal got better. But once you've switched to C, the sheer verbosity of
Pascal is bothersome. Instead of "{" and "}" Pascal uses "begin" and "end". It
uses "procedure" or "function" to introduce a function.

There's no going back, but I wish it was still available for learners. Java is
comparable in terms of programmer safety, but has too much ridiculous
boilerplate just to write "hello, world".

~~~
sand500
How does Pascal compare to python for absolute begginers?

~~~
utku_karatas2
Although I use Python extensively and started to forget about Pascal (ex
Delphi guy here), Pascal is a much better beginner language IMO.

Start with Python and you're most likely to be stuck with dynamic
typing/runtime mindset and it'll distance you too far away from OS level
native land.

OTOH starting with Pascal, you'll learn a great deal of low level (well,
relatively) stuff and that will make you appreciate the higher level languages
when the time comes and will let you leverage them more efficiently. Also as a
bonus, a big bonus I think, Pascal will let you feel at home if you ever need
C/C++/D in your career.

------
robterrell
It may seem quaint now, but Apple Pascal was a serious tool. I took AP
Computer Science in 1985 and the language taught was UCSD Pascal on the Apple
][+. (In the 80's, C on an Apple ][ was impossible. The only C compiler you
could get was for a card that went in the expansion slot that included a Z80
processor.)

When I went to college in 1986, Pascal was the primary language used in all
entry-level courses at Virginia Tech. (Turbo Pascal on an IBM PC -- $5 at the
student stores, if you brought your own floppy. I'm the weirdo who brought a
Mac Plus to school and used Lightspeed/Think Pascal.)

All of the classic Mac APIs used pascal calling conventions. Pascal continued
to be the language used for serious Mac development for a long time.

I can't find any references via Google, but Apple had an internal language
called "Classcal" which I was told was "pascal with classes". Eventually Think
Pascal adopted this object-oriented Pascal syntax.

Just today I was thinking about how great it was coding in Lightspeed Pascal,
when I was trying to get VS Code to display ligatures. Lightspeed Pascal
parsed the AST and auto-formatted all your code for you. Tabs became tab
stops, like a word processor. I still miss that; hard to believe today we're
still fighting about tabs v. spaces.

~~~
rbehrends
A major issue was that C compilers were actually fairly ill-suited for 8-bit
processors with limited memory, limited processing power, and at most a floppy
disk (if that) for external storage.

Pascal was designed to allow single pass compilation of programs, while the C
preprocessor alone was a source of what was immense overhead at that time. On
CP/M, Turbo Pascal blew all C compilers out of the water in terms of
compilation speed. The one C compiler I had on a ZX Spectrum at the time did
not actually implement the full language so that you'd have some memory left
over (I remember that the C type cast syntax was replaced with a keyword in
order to simplify the parser, for example).

That said, UCSD-Pascal on an Apple II (which we got to use in school as part
of our regular computer science course), was not all that convincing as an
implementation (even if the system as a whole was fairly impressive). Because
it used a bytecode interpreter (even if that bytecode interpreter leveraged
type information and was much faster than a bytecode interpreter for a
dynamically typed language), execution speed – including that of the
development environment, which was written in UCSD-Pascal itself – was still
pretty sluggish in comparison to an actually compiled language. (The UCSD
p-code in principle also allowed compilation to native code, but at least the
system I had access to – that was in the early 80s – didn't support that.) But
it was still more pleasant than many other compilers, and that was at a time
when cassette recorders were often still the primary external storage medium,
so people were more tolerant, when their point of comparison was systems that
literally included source code from cassette tape at compile time, because for
large programs you couldn't fit both the source code and the object code into
memory at the same time.

~~~
adrianmonk
C was also designed to compile in one pass, hence the need for forward
references. The preprocessor was extra overhead, though.

Also, from my recollection, Turbo Pascal was not just faster than C compilers.
It was also faster than other Pascal compilers. And pretty much any other
computer regardless of language. That was part of its appeal.

~~~
adrianmonk
Correction (in a comment since I'm past the editing time window): "pretty much
any other _compiler_ ".

------
dfan
In order to run Apple Pascal on my Apple ][+, I had to buy a "language card".
This was bigger than an index card (maybe 3 by 6 inches) and added _sixteen
whole kilobytes_ to your computer's RAM, beefing it up to a massive 64K and
rendering it capable of running such a system hog as Apple Pascal. I think it
was about a hundred bucks in the early 1980s.

Meanwhile, the Apple ][+ could only display 40 columns on screen, where of
course by "screen" I mean "television". (You could buy another big card to
give you enough memory to display 80 columns at a time, but who had the cash
to make another huge purchase like that?). Of course, 40 columns isn't enough
to write in a structured programming language with indentation like Pascal,
and in fact the Pascal program itself supported logical lines of up to 80
characters.

This issue was resolved as brilliantly as you might expect. You could toggle
between looking at the left half of your program (cut off at the 40-character
mark) or the right half. I'm not kidding.

~~~
ribs
Oh, I remember, although in my mind's eye, the 16K expansion card was bigger,
about as big as a graphics card of today.

~~~
flomo
I was lucky enough to have a second hand Apple ][ from a "hacker", it had a
][+ rom and was pretty much loaded to the gills with a "z80 softcard" and etc.
The slot 3 80-column card also had 16K RAM and was the only full-sized card in
the machine. (It also came with full documentation if you wanted to burn a
different font into a ROM.) So I had a 64K machine, but slot 0 was empty.
Unfortunately I never had docs for Pascal, so I never bothered learning it and
instead was mentally mutilated by BASIC.

A full-sized Apple card was a good bit less tall than a PC AT card and had to
be angled to fit the case. e.g. [0]

[0]
[http://www.applelogic.org/files/AVOChires.jpg](http://www.applelogic.org/files/AVOChires.jpg)

~~~
walshemj
Back in the day THE Gucci accessory for an Apple ][ was the clear Perspex top
cover to show off your collection of expansion cards

~~~
slantyyz
I would think the 10MB Sider HD was a bigger deal. A friend of mine used one
to run a BBS in Toronto back in the day. Before that, he had a custom setup
that had a pair of 8" floppies, which was pretty uncommon for the Apple ][
platform.

------
jzelinskie
I've been reading a lot about Niklaus Wirth recently. I read an interesting
piece about Oberon I found in an HN archive[0] that mentions Oberon usage on
Macs. I'm very tempted to buy "The School of Niklaus Wirth: The Art of
Simplicity" after reading a few things about him. I wish there were more
instances of "computing in a vacuum" like at ETH.

[0]:
[https://news.ycombinator.com/item?id=10058486](https://news.ycombinator.com/item?id=10058486)

~~~
microtherion
I studied under Wirth at ETH Zurich in the 1980s, so I got to interact with
him personally a number of times. His class on compiler construction was
particularly interesting. You could see how a philosophy of simplicity and
clarity in syntax and semantics would translate to simple and clear compilers.

The downside of this philosophy was that aspects of interacting with a
computer that were inherently messy tended to be swept under the rug: The
original "file" and "string" concepts as described in early Pascal reports
were simply unworkable, and combined with a marked disinterest in language
standardization efforts (which I personally suspect stems from Wirth's
involvement in Algol 68, although I have no direct evidence) led to each
implementation rigging up their own ad hoc solutions.

As a consequence, even TeX, a batch program with no fancy demands on hardware,
was not written in strictly "standardized" Pascal, but basically Knuth had to
assume the existence of a number of non-standard mechanisms.

~~~
drfuchs
As you indicate, the language described in Jensen and Wirth's 1975 "Pascal
User Manual" didn't have a way to open files with a name computed at runtime,
nor was there a way to close a file. TeX needed to be able to do these things,
as well as to have what C programmers would call a "default" case on a switch
statement, which was also missing from standard Pascal. Happily, almost all
Pascal compilers had these extensions; unhappily, the syntax was not generally
agreed upon.

Other than that, TeX actually used a strict subset of standard Pascal; quoting
module #3 in Volume B of Knuth's Computers & Typesetting: "Indeed, a conscious
effort has been made here to avoid using several idiosyncratic features of
standard PASCAL itself, so that most of the code can be translated
mechanically into other high-level languages. For example, the `with' and
`new' features are not used, nor are pointer types, set types, or enumerated
scalar types; there are no `var' parameters, except in the case of files;
there are no tag fields on variant records; there are no assignments
real:=integer; no procedures are declared local to other procedures."

As you also say, Pascal had virtually useless string types, but TeX worked
around that limitation itself, by managing its own string pool in a single big
array of characters, with a second array of pointers to where each string
started. A string was identified by its index in the later array. Through
careful design and coding, no general garbage collection of strings was
necessary, just the ability to forget the most recently-made string.

------
Animats
The page isn't rendering properly with ad blocking. The original memo is being
served from Storify. Where is it from? The Internet Archive. Here's the
original, which reads better directly from the Archive.[1]

[1]
[https://archive.org/details/Apple_Pascal_History_DTC_1992](https://archive.org/details/Apple_Pascal_History_DTC_1992)

------
malkia
I've started with Basic, some assembly (CALL-151) on my Apple ][ clone
(Pravetz 8C), but as soon as I got my hands on IBM PC/XT (or AT) Turbo Pascal
(the 30-40kb turbo.com) was just the right choice. It fit on one disk, there
was plenty more, while a Microsoft C/C++ compiler and linker each took a whole
separate disk.

The best thing I've loved were the .TPU files (but not sure whether TP4 or TP5
had them truly). There were no .h files to be included, or .lib (.a) to be
added, it worked just magically well (with some limitations).

I've moved to C/C++ later simply because, well it's a stupid reason. I was
writing a "File Manager" like app for DOS (just single column, not like Norton
Commander, FAR or Midnight Commander), and the only function in Turbo Pascal
5.0 to move files was just renaming a file in the same folder... Had I known
about inline assembly and be more brave, I would've stayed in Pascal Land (And
I was already familiar with Ralph Brown's Interrupt List)... But hey, this
stupid reason moved me to C/C++ as the builtin function there did it... then
again, soon after that I've started using more and more inline assembly.

I love C/C++ now (especially C), and where I used to be really good at Pascal,
I might have some hurdles reading pascal code today. Delphi was my last stop,
and while I like it, I switched to video game development, and Pascal was not
much used there (... Age Of Wonders I believe was written in some form of
Pascal and possibly some other games,... Also part of Xoreax's IncrediBuild
might've been, especially the part that does the C/C++ header processing, I
think it was since we had issues with it, and while debugging found something
pascal-ish in there, but don't remember now).

------
SwellJoe
My first programming language was (obviously) BASIC, but my second was Pascal.
I took AP computer programming in high school and it was taught with Pascal on
Apple II and IIe computers. My dad later bought me Turbo Pascal for the PC (I
remember a yellow box with "\+ Objects" on it, so it must have been 5.5 Pro in
1989), and I used it on his machine, but never did much with it other than
tinker. I finally got what I viewed as a real programming setup when I got
DICE (Dillon's Integrated C Environment) for my Amiga a couple years later.
Still didn't do much more than tinker, though, until I got a Linux box a
couple years after that and source code for everything was available for
poking at.

Anyway, Pascal was very common in education back then and Apply was very
common in education...ergo, Apple and Pascal went together a lot of the time.

------
fogus
For those of you still interested in this story, the author of the original
memo David Craig commented with clarifications, corrections, and further
information. It's a truly epic comment.

[http://blog.fogus.me/2017/07/20/pascal-at-
apple/#comment-808...](http://blog.fogus.me/2017/07/20/pascal-at-
apple/#comment-808933)

------
jenkstom
Pascal was one of my favorite languages (in the form of Object Pascal). I made
a living from it for decades. But Borland and a long succession of companies
killed it through mismanagement. It does still exist in the form of freepascal
and lazarus, but I've moved on to c#.

Pascal was great for people who didn't have curly braces in their muscle
memory. But I suppose I've gone fully over to the dark side now.

------
Lerc
Does the p-code compiler self host? I've been working on an emulator for an
imaginary 8-bit machine (AVR instruction set), and have been looking for
languafge options to run on it.

In the last few days, I've gotten FreePascal compiling for it, bit I would
also like to have languages that I can compile or interpret on the machine
itself.

------
swombat
I learned to program with Turbo Pascal on my PC back in the early 90s.
Language lite is fun.

And yet, when I clicked on this part of me was really just hoping this was
referring to nvidia's Pascal architecture, a hint that maybe they were finally
dropping the Radeon line and getting some decent video cards into their
machines.

One can but dream I guess.

------
jonjacky
The UCSD Pascal system, which ran on Apple II and many other computers in the
late 70s - early 80s, always displayed a menu (for whatever program was
running) across the top line of the screen. I wonder if that was the
inspiration for the Macintosh menu bar.

------
JustSomeNobody
A lot of us seem to miss Pascal. Makes me wonder if it'll ever have a
resurgence.

------
EvanAnderson
When opened w/o Javascript you see only the first paragraph and the timeline
at the bottom. I almost skipped over this because I thought there wasn't
anything interesting there.

~~~
Swizec
When I drive my car without an engine, it only goes downhill. I almost stopped
using cars because I thought there was nothing interesting there.

It's 2017. Turn on your JavaScript.

~~~
nxc18
It doesn't matter what year it is, JavaScript provides zero utility on a blog
except to give the author analytics.

Why do people hate the idea of documents so much? Imagine if you had to suffer
through a different app for every single book you read; that is what a js-
mandatory page is.

~~~
Swizec
I agree. Rendering static contents shouldn't rely on JavaScript.

And I still think disabling JS is like shooting yourself in the foot on
purpose.

Two wrongs don't make a right. Also I'm tired of people who always have to
point out "hurrr durr site don't work without JS". Nobody cares.

~~~
interfixus
' _Also I 'm tired of people who always have to point out "hurrr durr site
don't work without JS". Nobody cares_'

Apparently enough nobodies to tire you out.

------
carapace
Please, everybody, if you haven't read it, stop now, get a copy of "Humane
Interface", spend the weekend reading it, and then come in Monday and apply
it.

