RSS

Pascal and the P-Machine

15 Mar

Working with a small team of assistants, Niklaus Wirth designed Pascal between 1968 and 1970 at the Swiss Federal Institute of Technology in Zürich. His specification was implemented for the first time on the university’s CDC Cyber mainframe in mid-1970, and the system was finally considered complete and robust enough to introduce in beginning programming classes there in 1972. With his language essentially complete and with a working proof of concept in daily use, Wirth now shifted roles, from design and implementation to the equally daunting task of convincing computer-science departments around the world to give up their old languages and give his new one a shot. Like the PC industry of a decade later, the world of institutional computing was full of incompatible systems that often had trouble even exchanging data, much less programs. And yet Pascal needed to be available on all or most of these machines — or at least the ones commonly chosen by computer-science departments for pedagogical use — to have a chance of realizing Wirth’s goal of Pascal serving as an antidote to the deadly virus of BASIC. Porting the compiler by hand to all of those disparate architectures looked to be a daunting task indeed.

Wirth’s next epiphany should sound familiar if you read my earlier posts about Infocom: working closely with a graduate student, Urs Amman, he created a virtual machine, named the P-Machine, that could be hosted on all of these physical machines. They rewrote the Pascal compiler to output P-Code that could run under the P-Machine, just as Infocom later did in designing ZIL and the Z-Machine. (That’s of course no big surprise, as the P-Machine was the inspiration for the Z-Machine. If you’ve been reading these posts chronologically, I’m afraid we’ve rather put the cart before the horse.) Wirth, however, went one step further: he rewrote the Pascal compiler and other development tools themselves in P-Code, thus completing the circle. Once a P-Machine interpreter was written for any given platform, that platform could not only run the whole universe of already extant Pascal software, but also run the compiler, allowing users to create more software that could not only run on that platform but on all others for which P-Machine interpreters had been written. Similarly, updates to Pascal could be made instantly available on every platform hosting the language. Neat trick, no?

Beginning in 1973, Wirth began offering a “P-Kit” to anyone who wanted one. It consisted of the P-Code Pascal compiler and the source code, itself written in Pascal, for a P-Machine interpreter. The recipient need only (?) translate this source into a program runnable on their platform, working in assembly or some other high-level language, to get a complete Pascal environment up and running. To further encourage as many implementations as possible, Wirth published the specifications for the P-Machine in his book Algorithms + Data Structures = Programs, published in German in 1975 and in English the following year. The P-Machine did its job. By the mid-1970s universities were increasingly adapting Pascal as their standard beginning pedagogical language in lieu of comparative dinosaurs like BASIC and FORTRAN.

Meanwhile, the PC revolution was beginning, a development of which Wirth remained virtually unaware. He was after all firmly entrenched in the established institutional computing culture, and, further, he was working from Europe, where microcomputer technology was oddly slow in arriving. It would therefore be someone else, Ken Bowles of the University of California San Diego, who would spearhead a drive to bring Pascal and the P-Machine to microcomputers.

Bowles was an angry, frustrated man when he received his P-Kit in 1974. A devotee of interactive, time-shared computing over the old batch-processing model, Bowles had ascended to director of UCSD’s computer center in 1968. One of his first actions had been to replace the mainframe at the core of the center, an aged, batch-processing-bound Control Data system, with a state-of-the-art Burroughs capable of timesharing. Incredibly, however, Bowles got word from a lecturing stint in Oxford, England, in mid-1974 that the university’s administrators had decided, without even consulting him, to replace the Burroughs system with another big, traditional, batch-processing IBM mainframe. Even better, he got this news not from the university but from contacts at Burroughs, who contacted him asking why UCSD was pulling its contract. Bowles resigned his position as director in protest, going back to being just an ordinary professor, but could only watch helplessly as the trucks arrived to cart away the Burroughs system that had been essential to much of the research of him and his students. Worse, his programming classes would now have to be taught in the old way once again: instead of being able to write a program, compile it, and instantly see the result, students would have to type it out onto punched cards, deliver it to the computer center, then return the next day — if they were lucky — to see if it had actually worked. And rinse and repeat, ad nauseum.

Bowles saw the P-Kit as a possible solution to his woes, a chance to get a proper development environment back into the hands of his students. He would let the administrators have their mainframe, and try to get Pascal running on smaller, cheaper machines. Unlike his colleague in Switzerland, Bowles could even in 1974 see where the new generation of microchip technology was leading; he realized that desktop computers were on the horizon. While he would initially implement his P-Machine on a PDP-11 minicomputer, he could already envision the day when every student would have her own private computer to program. Thus the portability of the P-Machine was key to his project.

By mid-1976, Bowles and a small group of students had already come a long way, with a working PDP-11 Pascal environment that they had begun using to teach introduction-to-programming classes. (It replaced, not without controversy from traditionalists, the older FORTRAN-based curriculum.) And they had not just created a clone of Wirth’s compiler but had gone far beyond it. They had expanded greatly upon Wirth’s relatively stripped-down language, adding everyday conveniences such as better string handling and easier file access. Around it they had built what amounted to an entire Pascal operating system, all running in virtualized P-Code, similar to the interactive BASIC environments of the time but better; the text editor, for instance, was something of a marvel for its time. When UCSD Pascal began to spread, their tinkering with Pascal raised a fair amount of ire from some quarters, not least from Wirth himself, a pedantic sort who regarded the language in its original form as perfect, with everything it needed and nothing it didn’t. Still, UCSD Pascal would soon supersede Wirth’s own implementation as the standard, most notably inspiring what became the commercial juggernaut Turbo Pascal. And whatever his misgivings at the time, Wirth has since come to acknowledge the enormous role UCSD Pascal played in popularizing his design in the PC world.

In July of 1976, Bowles and his students brought their Pascal up for the first time on a microcomputer, a Z80-based system built from a kit. He describes this moment as a “revelation”; all of the software his team had created for the PDP-11 version just worked, immediately, with no changes whatsoever.

Bowles had begun his project to provide a better tool for his students, but it was soon obvious that UCSD Pascal had commercial potential outside the university. The first partnership was with a tiny startup called Terak, who had developed a workstation called the 8510/a that was basically a stripped-down, semi-compatible clone of the PDP-11 minicomputer with added bitmapped graphics capabilities that were stunning for their time. Having been first implemented on a PDP-11, UCSD Pascal was of course a natural fit there. Bowles went on the road with Terak to demonstrate the system, where the programming environment combined with the machine’s display capabilities inspired “gasps of amazement.” Terak machines soon became the standard platforms for running UCSD Pascal at UCSD itself.

The greenest pastures, however, beckoned from the burgeoning PC market. Microcomputer users and programmers were already as early as 1977 trying to reckon with the incompatible machines on the market: the TRS-80, Apple II, and Commodore PET, not to mention the dozens of kit and boutique computers, were all incompatible with one another, fragmenting an already tiny software market. Yes, these machines all ran BASIC, but each hosted a subtly different version of the language, crafted in response to the hardware’s capabilities and the whims of the machine’s manufacturer, enough to guarantee that all but the simplest BASIC programs would need some translation to move from platform to platform.

Every programmer had to deal with this reality, whether by coding in BASIC and translating as necessary (as did the general-purpose magazines, who often published type-in listings footnoted with the changes needed to run the program on platforms X, Y, and Z), developing some sort of portable game engine (as did Scott Adams, Automated Simulations, and Infocom), or just focusing on a single platform and hoping it was enough to sustain a business (as did the Apple II-specific supercoders I mentioned in my last post). The UCSD system offered another solution. Beginning in 1978, Bowles and his students started a quasi-business selling versions of the system for S-100-bus PCs to anyone who asked for one for $15. Those machines, descendents of the original Altair and generally either built from kits or provided by boutique manufacturers, inhabited a somewhat different ecosystem than the friendlier, more mass-market trinity of 1977, being the domain of the hardcore technical set that made up the core of Byte magazine’s readership and, increasingly, business users. (Tellingly, games, which dominated early software on the trinity of 1977, were few and far between on these machines.) For all that, however, there were quite a lot of them out there, and quite lot of their owners were eager to experiment with UCSD Pascal in lieu of their normal operating system of choice, Digital Research’s CP/M.

Bowles first met Steve Jobs and Steve Wozniak at the very West Coast Computer Faire at which they unveiled the Apple II. Jobs was already eying the education market, eager to forge “respectable” ties for Apple, and eager to bring professional-level software to the platform, and so the two men remained in intermittent contact. The relationship was given a boost the following year when Bill Atkinson, a UCSD alum, came to work for Apple. Atkinson, a computer engineer whose word held a great deal of sway with the un-technical Jobs, was greatly enamored of UCSD Pascal, convinced it would be a great booster for the Apple II. Still, that remained a problematic proposition at this point. Although UCSD Pascal had been designed to run on tiny machines in comparison to its inspiration, there were inevitable limits. The system was designed for a machine with at least 64 K of memory. By contrast, the first Apple IIs could be purchased with as little as 4 K, and seldom exceeded 16 K. It was an obvious nonstarter. And so the relationship between Apple and UCSD remained just talk for the moment.

In mid-1979 Apple introduced the dramatically improved Apple II Plus, which generally sold with what was taken at the time as the machine’s maximum possible memory of 48 K; the 6502 CPU used in the Apple II can only address 64 K at one time, of which 16 K was used by the ROM memory that hosted the machine’s BASIC-based operating system. They were getting close, but an Apple II version of UCSD Pascal still seemed out of reach. As it turned out, however, they were close enough that some clever hacking could get the job done.

The UCSD system would by design completely take over the machine. This meant that the 16 K of BASIC ROM would be superfluous when the machine was running the new operating system. Therefore Apple came up with a new expansion card (reason to bless Woz’s insistence on having all those slots again!) containing 16 K of RAM memory. The user could choose whether the CPU addressed this RAM (for running UCSD Pascal), or the standard 16 K of ROM (for running other software). Just like that, they had their 64 K machine.

The USCD Pascal software, renamed to Apple Pascal, was sold as a single package along with this “Language Card” for about $500 from shortly after the arrival of the Apple II Plus. It transformed just about everything about the Apple II; even its disks used their own format, unreadable under the normal Apple II environment. It would not be an exaggeration to say that an Apple II equipped with Apple Pascal was a completely new and different machine from Woz’s original creation, with a personality all its own. The inability to exchange programs and data with users who hadn’t purchased the system was, undeniably, a drawback. On the plus side, however, the user got easily the most advanced development environment available on any microcomputer of this era. Not only did she have access to the Pascal language in lieu of BASIC, but Apple and UCSD worked in quite a lot of extensions to take advantage of the Apple II’s unique bitmapped graphics capabilities, borrowing from the older Terak implementation. I’ll come back to that a couple of posts from now, when I demonstrate a concrete example of Apple Pascal in action. And we’ll start on the story that will lead to that next time.

 
 

Tags: ,

13 Responses to Pascal and the P-Machine

  1. David Cornelson

    March 15, 2012 at 5:02 pm

    We had a Terak PC at my high school in 1982. It was the slickest machine around at the time. It was blazingly fast and had amazing graphics capabilities. Oddly my computer specialty high school never got into Pascal. They taught COBOL, PDP Basic, and RPG II. After reading this article, this seems very short-sighted. It’s also strange that BASIC was the main choice for DEC when better alternatives existed (Pascal).

     
    • Jimmy Maher

      March 16, 2012 at 7:04 am

      I actually updated the post slightly to give a few more props to the Terak’s graphics capabilities, which apparently were very impressive…

       
  2. ZUrlocker

    March 16, 2012 at 6:18 am

    I used Wirth’s Pascal on a CDC Cyber 170 in college back in ’82. I also owned an Apple II+ at the time, but I found the UCSD P-system to be very cumbersome, especially on a 40 column screen. But the following year, I bought an IBM PC (with floppies –this was before the XT was available) and was amazed with the great performance and UI of Turbo Pascal. This was the first time you got a first class programming language and integrated development environment on a microcomputer. Some years later, I worked with Anders Hejlsberg and others to help create Delphi and that was a heckuva a lot of fun!
    –Zack

     
    • Jimmy Maher

      March 16, 2012 at 7:02 am

      Wow! Very cool! I was a great fan of Borland’s products. When I bought my first Windows machine, I still remembered my Turbo Pascal experience (see comment on previous post) so well that I sought out Borland again. I wasn’t terribly interested in going back to Pascal, but luckily they had something called C++ Builder. I eventually implemented my Filfre interpreter using that, and, while I wouldn’t start any new projects with it, still keep a copy installed just to maintain the terp.

       
  3. Rupert

    March 8, 2013 at 10:54 am

    Fantastic history, thanks for writing this. I’ve been toying with writing a p-code machine for a while now and enjoy learning about the history of said machines. – Rupert.

     
  4. Jecel Assumpcao Jr

    February 13, 2014 at 2:23 am

    A bit of trivia: the faint “Pascal ” seen at the top of the ad is actually the phrase “Pascal Spoken Here” on the other side of the page bleeding through. That means it was actually mirrored, and the reason for this was that you could rip out the page and use an iron to create a t-shirt like the guy in the ad is using.

     
  5. cph1776

    May 31, 2017 at 1:56 am

    I remember using Apple Pascal during my time as a UCSB student (1983-1987). The Apples there had an 80-column card, much nicer than trying to make it work with 40 columns. (This was pre-Apple IIe, so I don’t recall if it was compatible with the bitmapped graphics or not…)

    There was also a version of Fortran that used the p-system. (Silicon Beach Software was the company, IIRC). It wasn’t 100% compatible with Fortran 77, though.

    A few on-campus departments had Teraks with the p-system as well; I distinctly remember using one as part of a science project.

     
  6. Tony Chesser

    August 14, 2017 at 4:39 am

    The “Language Card” as it was known, would only go into one slot in the machine (slot 7, IIRC). It had a small ribbon cable which went down to a DIP header. You had to pull a memory chip out of the Apple //+ mobo (it was the only “socketed” memory chip on the mobo), plug that into a waiting socket in the Language card, then plug the DIP header into the now-empty memory-chip socket. Without accidentally bending any pins on the transplanted memory chip or the DIP header.

    There was some serious hardware hackery going on, getting that to work.

    Once it was done, you could run Apple Pascal on it. Or Apple Logo. We were teaching 5th and 6th graders Logo when I was a high school junior. We didn’t have enough computers to go around, but no one seemed to care.

    By the time I started my senior year of high school, we had a bunch of Apple //e machines which came with 64k, 80-column cards and a keyboard with a layout which more closely mimicked the Selectric typewriters in the typing class; quotation marks were -apostrophe, rather than -2, as found on the //+. I had Apple Pascal my senior year. Realized pretty quickly this was NOT Apple DOS 3.3 with Applesoft Basic.

    Ahh, the memories ….

     
  7. mycophobia

    September 27, 2018 at 6:40 pm

    typo: “epipheny”

    Love the site btw, it’s kept me from doing actual work for many hours so far

     
    • Jimmy Maher

      September 28, 2018 at 8:38 am

      Thanks!

       
  8. Wilhemina

    October 27, 2018 at 6:34 pm

    Which can be also the wild card, the Sphinx, hieroglyphics, the scarab and other representations.

     
  9. Will Moczarski

    December 1, 2019 at 12:26 pm

    and quite lot of their owners
    -> quite a lot

     
  10. Daryl Cheshire

    May 21, 2023 at 9:52 pm

    I loved Apple Pascal in 1984 on an Apple 2e. I used two Shugart 140k drives and I knew the compiler found an error as it would read the second disk to find the error codes.
    I eventually borroed mone to buy the 5MB ProFile which was a game changer. Eventually I got an Apple 2gs and a 1MB RAM disk from where I booted into Pascal.
    I had a lot of fun but Pascal gave me the foundation to play with other languages and helped my career prospects.

     

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.