
A Mystery of Unix History - gioele
https://changelog.complete.org/archives/10051-a-mystery-of-unix-history
======
Animats
Because EMACS wasn't developed for the PDP-11. It came from the MIT ITS and
Stanford SAIL systems, which had real "meta" keys.[1] Those keyboards also had
a "Top" key, an additional shift for extra symbols on top of the keys. See
"MIT Space Cadet Keyboard", and Symbolics keyboards.

The control-S/control-Q flow control only worked on UNIX in "line mode", which
also did backspace and such. VI turned that off and ran in raw mode. Before
BSD, UNIX mostly ran in line mode. The TCP/IP implementation we used, a
heavily modified 3COM UNET, predated BSD networking. It normally ran in "line
mode", and when running VI remotely, VI switched the pseudo-terminal to "raw
mode", which caused the Telnet connection to send the options DON'T ECHO[2]
and DO SUPPRESS GO AHEAD.[3] The connection was now transparent to special
characters. This was necessary on the rather laggy links of the time. Exiting
VI restored line mode.

If VI crashed, or you killed it, or, when job control came in, you switched
tasks, you were stuck in raw mode, and had to reset the terminal session by
typing "stty saneLF". You actually had to type LF, because CR->LF translation
was suppressed in that mode.

BSD didn't bother with this, and ran terminals in remote echo mode all the
time, which required lower lag connections. Berkeley was mostly IP over
Ethernet at the time, without much long-haul, so that worked for them.

[1]
[http://xahlee.info/kbd/iold51593/SAIL_keyboard_96232.jpg](http://xahlee.info/kbd/iold51593/SAIL_keyboard_96232.jpg)
[2] [https://tools.ietf.org/html/rfc857](https://tools.ietf.org/html/rfc857)
[3] [https://tools.ietf.org/html/rfc858](https://tools.ietf.org/html/rfc858)

~~~
drfuchs
Just to not leave a misimpression: Emacs (and TECO) never ran on the Stanford
Sail machine (which ran the Waits OS); The "E" editor that was native to
Sail/Waits used combinations of the Meta and Control keys for commands, which
perhaps helped inspire their use in Emacs (written originally ITS at MIT).

It's worth noting that at Sail, the Meta and Control keys simply sent extra
"bucky" bits on top of the 7-bit character code, resulting in a 9-bit input.
And the actual ESC key was intercepted by the Waits for special commands from
the user, and was never delivered to user-land programs (ESC-H tells the OS to
hide your screen from others; ESC-I asks the OS to send an interrupt signal to
your program; etc). The octal location 033, where ESC lives in Ascii, was
instead used for the character "not-equals" on Sail; similarly, most of the
other locations in the range 001-037 were used for other special characters
that aren't in Ascii, and all were typically generated with a Top key-
combination press. The whole notion of Control automatically stripping off the
high-order bits of a character was foreign.

~~~
naniwaduni
> octal location 033

 _of course_ this predates the invention of hex, or at least the modern
conventional notation for it

~~~
kps
Pre-PDP11, DEC had machines with 12, 18, and 36 bit words. Those are all
multiples of 3, so octal was more natural. (For the 16-bit PDP11, the
instruction format made octal natural.)

------
rhinoceraptor
Bill Joy used an ADM 3A[1] terminal, and looking at the keyboard layout
explains vi's key mappings almost entirely.

There are arrow keys printed on HJKL (accessed via control), escape is left of
Q, control is left of A, and colon has a dedicated key rather than being
shift+semicolon.

Another tidbit is that the home key is also used for tilde, which explains its
association with the home directory.

1:
[https://en.wikipedia.org/wiki/ADM-3A#/media/File:KB_Terminal...](https://en.wikipedia.org/wiki/ADM-3A#/media/File:KB_Terminal_ADM3A.svg)

~~~
GaltMidas
This makes so much sense, and now looking at this image, I wonder if it
explains "tabs vs spaces".

~~~
Reelin
It does seem like an additional reason, but I'm convinced tabs were (are?)
disliked primarily for historical and technological reasons. Historically the
tab key worked with a tab stop; there's always friction when you switch
paradigms. Technologically, accommodating a variable width non-printing
character on an 80x25 character-mapped display for no particular reason must
have seemed both gratuitous and wasteful when you consider the typical
hardware of the time (monochrome terminals, CPUs on the order of 1-50 MHz, 1-5
MB RAM, < 1 MB ROM, etc).

~~~
wahern
> disliked primarily for historical and technological reasons

Huh? AFAIU, all the historical source code uses tabs for indentation. Both K&R
and BSD style uses hard tabs, as does Linux kernel style and most older GNU
project code for that matter. Various Unix programs _assume_ tabs, for example
indentation elision in shell heredoc syntax ("<<-") only works for tabs.

Soft tabs (spaces) has been a relatively new thing in the C/Unix world. You
may not notice it because, working as well as they do, hard tabs magically
indent according to your local preference, so hard tabs aren't noticeable.[1]

[1] What doesn't work is right-hand alignment. That's most noticeable in
modern BSD code, where the style is to tab-align variable types and names into
different columns. If your tab stop isn't set to 8 (the required tab stop),
they don't line up. Most hard tabbers don't mix indentation and alignment,
anymore.

EDIT: Here's the earliest source code for vi I could quickly find:
[https://github.com/n-t-
roff/ex-2.2/blob/220a2cfa/ex.c](https://github.com/n-t-
roff/ex-2.2/blob/220a2cfa/ex.c) It uses hard tabs. It's also still using pre-
ANSI function syntax, suggesting this code wasn't cleaned up before committing
to Git.

~~~
Reelin
Ok apparently I'm super ignorant about this. WTF are people going on about
spaces for if hard tabs are the historic standard? I always assumed that Go
was progressive, C++ was the norm (ie had no preference), Python and Nim were
designed by diehards clinging to the past, and that people were exhibiting
their rather famous resistance to change. Apparently this is completely wrong?

I seem to have made assumptions due to only running into spaces in "old"
places such as Python, Vim, Emacs, etc. To be fair, this all happened well
before I was born. Why would software developers of all people try to do away
with a useful abstraction?!

Oddly, the linked keyboard doesn't appear to have a tab key but the Vi source
code you found contains them? Am I missing something obvious?

(`/* Copyright (c) 1979 Regents of the University of California */`, that's
some impressively old code to find on GitHub.)

Re BSD: Yeah, tabs don't work for alignment almost by definition. I'm
surprised anyone was crazy enough to author a code style that called for it.

~~~
pjc50
Bit strange thinking of Python as "old" .. anyway, what I suspect happened was
that tabs were the "new" innovation - in the post-punchcard era. Punchcards
couldn't meaningfully have a tab _character_ , but they could have fixed
character _positions_ , and this feature was required by COBOL and FORTRAN in
their day. It was still present in the F77 standard.

I think the other thing that got in the way of standardising on TAB was that 8
character indent is too much, but once you let people configure it it's no
longer consistent between systems.

> that's some impressively old code to find on GitHub

You may like
[https://github.com/chrislgarry/Apollo-11](https://github.com/chrislgarry/Apollo-11)

~~~
jlokier
> Bit strange thinking of Python as "old"

Python is about 30 years old. Started by Guido van Rossum in December 1989.

Python is older than HTTP, older than the Web.

It's older than most programming languages still in common use today (TIOBE).

I think most people would think of Python as "old" if they thought about its
history. Its current cool factor in AI and employment makes it seem newer than
it is.

------
tyingq
I believe VT52 and VT100 terminals have a physical ESC key where you would
expect it to be. On newer models, like VT220, etc, you can use the setup
screen to put them in VT100 mode. Once you do that, the F11 key will function
as an escape key.

Also note it was viewed as a weird choice to omit the key at the time.
Televideo, a competitor, called it out in their ads:
[https://imgur.com/a/u7KHRjQ](https://imgur.com/a/u7KHRjQ)

Somewhat interesting that Apple recently took away, then gave back the ESC key
on their pro laptops.

~~~
GeorgeTirebiter
I _still_ want my Meta key! How can we do Ctrl-Alt-Meta-Cokebottle? But,
seriously, having three "control-like" keys gives us 8 'name-spaces' using
different combinations of Ctrl / Alt / Meta. Pretty convenient.

~~~
SolarNet
I still want arbitrary modifier keys.

This is a feature of some game engines which allow people to use arbitrary
keys (or combinations) as modifier keys. Which allow for less motion of the
hand over the keyboard, by simply being able to hit the same keys (with some
modifiers) quickly.

~~~
zozbot234
You would need an N-key-rollover keyboard to be able to do this, at least in
the general case. Baseline keyboards do not register overlapping keypresses
correctly, unless you are using the ordinary modifier keys.

~~~
SolarNet
Sure, but a lot of gaming hardware supports this, and it's a hardware issue.
If one is customizing their editor to the point of using arbitrary modifier
keys, they will probably be willing to buy a custom keyboard.

Also while on the subject 8 key rollover, which is pretty common, is probably
more than enough.

------
drfuchs
The article is simply incorrect. The VT100 (and VT52 before it) had an ESC
key, right where you'd expect it to be. Just about any terminal you might have
bought in the 1970's had one.

It's shown clearly in the document the article (indirectly) points to:
[https://vt100.net/docs/vt100-ug/chapter1.html](https://vt100.net/docs/vt100-ug/chapter1.html)

~~~
pdw
Those have an escape key, but the VT220 doesn't.

------
jlv2
Back then I wouldn't use a DEC terminal newer than a VT-100 because of the
lack of an ESC key. The 220s were physically great terminals, but the keyboard
layout was horrific for using _vi_.

Around 84 we started evaluating a purchase of hundreds of terminals for the
university, and eventually settled on the Wyse WY-75, mostly because it was
ANSI/VT-100 compatible _and_ had an escape key.

DEC didn't care, because they didn't use the ESC key in VMS.

------
messe
> Ctrl-3 and Ctrl-[ could send the character. However, this is downright
> terrible for both vi and Emacs (as this is the only way to trigger meta
> commands in Emacs).

Anecdotal, but I use Ctrl-[ in vi all the time. More comfortable the escape
key in my experience. I've tried jj and jk, but I inevitably end up on a
system without my .exrc or init.vim at some point, and struggle. Ctrl-[ has
the benefit of working _everywhere_.

------
jasoneckert
UNIX wasn't the only OS that those terminals were sold for. DEC had this crazy
notion that people should be using VMS.

~~~
mark-r
Even VMS wasn't the first. The PDP-11 had its own operating systems, RTS and
RSTS.

------
simonblack
All of the RS232 (serial i/o) VDUs had hardware handshaking. A common problem
was that some serial _cables_ lacked ALL the wires required. i.e. the bare
minimum serial cable has only 3 wires (ground, in, out). Cables with more
wires have greater capabilities (handshaking, modem control,etc,etc).

[https://en.wikipedia.org/wiki/RS-232](https://en.wikipedia.org/wiki/RS-232)

~~~
jgoerzen
I have a vt420, vt510, and IBM3151 and not one of them do RTS/CTS like we'd
expect. The vt510 can apparently do that on the DTR/DSR pins, but the vt420
and below cannot, and neither can the 3151.

~~~
therealcamino
The VT220 had RTS/CTS. You had to turn it on in the menus, and you needed a
cable with all the pins connected, but it worked fine.

[http://www.bitsavers.org/pdf/dec/terminal/vt220/EK-
VT220-TM-...](http://www.bitsavers.org/pdf/dec/terminal/vt220/EK-
VT220-TM-001_VT220_Technical_Manual_Nov84.pdf)

------
Isamu
> why would both of these editors be developed in such a way that they are
> downright inconvenient to use on the hardware on which they most frequently
> ran?

As other comments note, they were developed on earlier models or non-Dec
terminals.

Also Emacs was not developed on Unix. The first Unix Emacs was created by
James Gosling of Java fame.

~~~
aap_
Certainly not. The first emacs was created for the TECO editor on ITS by
various people. It was further developed and maintained by RMS. Gosling's
emacs came a few years later.

~~~
invsblduck
Then there's this debacle I've never spent enough time getting to the bottom
of...
[https://www.reddit.com/r/programming/comments/dhrcxw/james_g...](https://www.reddit.com/r/programming/comments/dhrcxw/james_gosling_on_how_richard_stallman_stole_his/)

~~~
bbanyc
[https://github.com/larsbrinkhoff/emacs-
history](https://github.com/larsbrinkhoff/emacs-history) has the details...
there's some Gosling code (notably display.c with the skull-and-bones warning)
in Emacs 13, but none that I can find in 15 and later.

------
devicetray0
Is there a good book on Unix history? Something accessible like "Where Wizards
Stay Up Late: The Origins Of The Internet"?

~~~
enf
Also A Quarter Century of Unix by Peter Salus,
[https://wiki.tuhs.org/lib/exe/fetch.php?media=publications:q...](https://wiki.tuhs.org/lib/exe/fetch.php?media=publications:qcu.pdf)

~~~
l1k
Thanks for this blast from the past. I bought the book in 1997 as a sophomore
student at university. My favorite book at the time. Leafing through the PDF
after all these years I came across some gems I hadn't appreciated back then:

On page 161 the author mentions in passing that Eric Schmidt had been working
on BerkNet. THE Eric Schmidt. The Google Eric Schmidt.

Earlier the book mentions that Bill Joy was able to hire a developer with
money they got from DARPA. That developer was Michael Toy and later Sam
Leffler. There's a movie called Code Rush about the open-sourcing of
Netscape's source code in 1998 (which begat Mozilla and Firefox) and Michael
Toy was the project lead for the open source effort back then. Sam Leffler
later developed TIFF.

------
kazinator
> _According to the EmacsOnTerminal page and other research, at least the
> vt100 through the vt420 lacked Esc by default._

What?

[https://en.wikipedia.org/wiki/VT100#/media/File:DEC_VT100_te...](https://en.wikipedia.org/wiki/VT100#/media/File:DEC_VT100_terminal.jpg)

------
Miner49er
Here's someone asking about it in an old newsgroup from 1993:

[https://groups.google.com/forum/#!topic/comp.terminals/a73kE...](https://groups.google.com/forum/#!topic/comp.terminals/a73kE6H6Cic)

~~~
taborj
Interesting to note that on my current Linux system, both CTRL-3 (ESC) and
CTRL-8 (backspace) work as well.

~~~
Jaruzel
And so they should. They are both standard ASCII codes.

