Emacs fulfills the UNIX Philosophy
Part 5: The parallel histories of UNIX and Lisp
This is part 5 of a 6-part series of articles defining what the UNIX philosophy is, what Emacs is, and discussing whether Emacs fulfills the UNIX philosophy.
0. Introduction 1. Emacs is an app platform 2. What is the UNIX philosophy 3. Seems like Functional Programming 4. Lisp does FP better than UNIX shell programming 5. The parallel histories of UNIX and Lisp 6. Response to common criticisms
In part 4 of this series I talk about how the Bourne shell languge falls short of being a FP language. In this article I consider the question of whether UNIX may have been inspired by Lisp, as both were developed in part at the MIT CSAIL laboratory. But as we shall see, the UNIX engineers had left CSAIL just before John McCarthy, inventor of Lisp, would set up shop there. I conclude that UNIX takes no inspiration from Lisp, but both UNIX and Lisp share some features in common, especially REPL-based software development techniques in a Command Line Interface (CLI), because both were invented around the time when the CLI was invented.
A digression: the pre-history of the CLI
The history of Lisp and UNIX both originate around the time that computer companies like IBM and DEC started to develop time sharing systems in the early 1960s, because it was this innovation that naturally led to interactive command line interfaces (CLIs) and the Read-Eval-Print Loop (REPL). It was around this time that people would first begin philosophizing about the best ways to use computers in interactive CLIs.
Several computing platforms would eventually build interactive CLIs, and the idea would be wide spread well into the personal computing era of the 1970s - 1980s, until they would go out-of-vogue with the rise of GUIs. Interestingly, some of the very first CLI systems, Lisp, and UNIX, remain useful even half a century later, surviving beyond most other CLI systems of the era which have now dissapeared. Why this happened might be because of the separately enduring philosophies that guided the design of systems of Lisp and UNIX.
What were time sharing systems?
The way people used computers in the 1950s was to write a program as a batch of punch cards using punch card typewriters, then place your batch into a queue where the system operator would load your program from the punch cards into memory, then execute the program. The operator would then take the print-out resulting from the execution of your program and send it to you, hours or days later. Imaging waiting a day or more for your program to run, only to find out that there was typeo in your code.
Punch cards were not only slow, but notoriously unreliable, introducing errors into data due to poor electrical conductivity in the point contacts. Getting rid of punch cards was an obvious way to improve how computers were used. It was not be long before technology would progress to the point where punch card typewriters could be modified to send electrical signals which could enter characters directly into computer memory. Conversely, strings of characters in computer memory could be transmitted back to the typewriter as electrical signals that would actuate type to stamp each character onto the paper feed.
This technological advancement would eventually allow the
typewriter terminals to be connected to a computer over a telephone
network — the teletype terminal.
And with the
technological advancement of Teletype terminals, larger numbers of
people would be able to all use the computer at once. All that was
needed was an operating system that could allow multiple users, each
with a teletype terminal, to all share the limited computing
resources: this is what the Time Sharing Systems were
for.
Time sharing systems were a major improvement over the old ways of using computers. The huge, expensive mainframe computers used in accounting departments, which would often sit idle, could now be used all the time by selling computing time to remote users over teletype terminals. As a result, more people — mathematicians, scientists, engineers, students — could now have access to computers, which led to even more scientific innovation.
Time sharing systems also improved the quality of computer
interaction. Rather than waiting for the print-out of your punch
card program to come back hours or days later, you could use a
teletype terminal to enter commands over a telephone line
(a command line
) directly into the computer, and then
get results back almost immediately. Computers could now, for the
first time, be used interactively, and it would not be much
longer before computer engineers of the era would start to
philosophize about how to most effectively use this new interactive
computer technology.
1958-1963: Lisp, and the first REPL
The Lisp programming language was invented in 1958 at MIT by professor John McCarthy, written on punch cards in the assembly language for the IBM 704 mainframe. This was not even a full year after the USSR launched the Sputnik I artificial satellite that kicked the Cold War into high gear. The Cold War would drive incredible demand for science and technology research, and with it, demand for more access to computers. Not long after inventing Lisp, McCarthy would become more involved in time sharing technology.
With more demand for computing time, it became clear that a
market for smaller, cheaper versions of mainframes computers would
also be profitable. Several companies would begin developing and
selling these minicomputers
including the DEC
corporation. Minicomputers were still quite large, but reduced
capital cost of ownership compared to mainframes, and thus had
potential for higher profit margins on selling computing time. So by
the mid 1960s there were more computers in production, and thanks to
time sharing, computers were more redily available to a larger user
base.
With the recent innovation of interactive CLIs, and now the more wide-spread availability of less expensive minicomputers, Lisp would only have to wait 5 years (until 1963) after first being published before someone would try writing an interactive Lisp interpreter — the first Lisp REPL — for the PDP-1 computer. McCarthy would recall that the DEC-1 did not have enough memory to do any useful symbolic computation. But only a year later, in 1964, a new Lisp REPL would be written for the more powerful PDP-6 computer, and this would be the first time a truly useful Lisp REPL was realized.
1964: MIT, Bell Labs, and the GE corporation collaborate on Multics
Also in 1964, the General Electric corporation, Bell Labs, and MIT, would begin a collaborative research effort into time sharing systems. This would become the Multics operating system, and two engineers, Brian Kernighan and Dennis Ritchie, would work on this project, and would eventually go on to make history inventing the C programming language, along with contributing to the development of UNIX. To facilitate research projects like Multics, MIT would establish the Computer Science and Aritifical Intelligence Laboratory, CSAIL. In time, John McCarthy would come to work at CSAIL, and would bring Lisp with him to do symbolic computing and artificial intelligence, along with other AI founders like Peter Norvig and Marvin Minsky. But by the time McCarthy started working at CSAIL, Kernighan and Ritchie were no longer working on Multics, they had moved on to invent the C programming language, which would then be used to develop UNIX. In every recounting of the history of UNIX by the engineers involved, none of them mention John McCarthy or Lisp as the inspiration for their interactive computing environment.
In 1969, around the time the US landed a man on the moon, the former Multics engineers would begin work on UNIX at Bell Labs, incorporating many of the ideas they had devised for the Multics project. Both Multics and UNIX were time sharing systems, so using it through an interactive CLI was one of the fundamental assumptions that would guide the design of the user interface.
UNIX was a big hit. The MIT CSAIL laboratory would eventually buy computers running UNIX OS sometime in the 1970s, and MIT professor Richard M. Stallman talks about how he had used these UNIX computers while developing the first pieces of GNU software in the early 1980s. So Emacs was one of the earliest interactive Lisp REPLs ever programmed for the UNIX OS.
But it is unfortunate that UNIX was not inspired by Lisp. In
McCarthy's 1960 paper on
Lisp, Recursive
Functions of Symbolic Expressions and Their Computation by Machine,
Part I, he specifically cites the 1941 paper on
the Lambda
Calculus by mathematician
Alonzo
Church (a contemporary
of Alan
Turing), as the model for the Lisp programming language. This is
why anonymous functions are called lambda
s. The UNIX
people were not guided by Lambda Calculus, and without the solid
mathematical foundations that McCarthy used for Lisp, UNIX shell
programming turned out to not be anywhere near as elegant as
Lisp.
Conclusions
Even though Lisp and UNIX were developed by different groups of people, with different guiding philosophies, both systems emerged during a time when interactive CLI technology was starting to reshape how people thought about using computers. And I would argue that the UNIX Philosophy is really just describing the same techniques and computer usage habits that had been discovered independently at the same time (slightly earlier than UNIX) as Lisp's notion of functional programming in a REPL. Unfortunately, without the Lambda Calculus as a guide, the UNIX Philosophy turned out to be a misguided, incomplete description of functional programming.
I hope by now you are convinced that the UNIX Philosophy
of every program does one thing, and does it well
is indeed
similar to, though not inspired by, the principles of functional
programming that were pioneered by Lisp — you could even argue
that UNIX is perhaps a naive formulation of functional
programming. And I hope you might agree that Emacs, as a Lisp
programming language originally implemented on UNIX systems, allows
you to do functional programming in a UNIX Programming Environment
better than you can do with a Bourne shell language such as
Bash. Therefore Emacs does actually follow the tenets of the UNIX
Philosophy, in some ways, even better than the UNIX Programming
Environment does so itself. In
the final entry
of this series I respond to some common criticisms that have
been made to these arguments, which I have heard in conversations I
have had with some of my peers.