[3B2-8] man2009040110.3d 31/10/09 18:24 Page 110

Anecdotes The Beginnings of TECO

Dan Murphy Editor: Dave Walden

I came up with the name TECO in 1962 while sitting from hours to minutes. I could do it several times on in Ye Hong Guey, my favorite restaurant in Boston’s the machine in a one-hour session. Chinatown during my undergraduate years at the Mas- In a smart move for a young corporation, DEC had sachusetts Institute of Technology. I had been working donated a PDP-1 to the Research Laboratory for Elec- on a little program to help me write other programs, a tronics (RLE) at MIT, and it was sitting in a room common activity in the day when a computer (the Dig- more-or-less available for anyone, including undergrad- ital Equipment Corporation PDP-1) would be delivered uates, to play with. There were soon many takers. Be- with almost no software. My program had gotten to the cause only one person could be using the PDP-1 at a point that it needed a name, so my friend Pete Peterson time, computer time quickly became scarce, and it and I were kicking around possibilities and their was still necessary to do as much program preparation acronyms. as possible offline. We did this with Frieden Flexo- Years later, TECO would be known to mean Text writers, typewriter-like devices with a paper tape reader Editor and Corrector and so described in its documenta- and punch. Programs had to be handwritten first tion. However, the original meaning—the one we came because editing capabilities on the Flexowriter were up with that night at the corner of Oxford and Beach nonexistent. The most you could do was nullify a pre- streets—was Tape Editor and Corrector. viously punched character by backing up the tape punch and over punching the same line. Interactive computer use on the PDP-1 Paper tape was more convenient than punched cards We used the term ‘‘tape’’ because punched paper in some ways. It was lighter than cards for a given num- tape was the only medium for the storage of program ber of lines of program, and if you accidentally dropped source on our PDP-1. There was no hard disk, floppy it, it did not shuffle all your lines of code. This was also disk, magnetic tape (magtape), or network. There its biggest weakness. When you needed to modify a was no , only the paper tape reader program—add, change, or delete a few lines—you and punch and a console typewriter. The paper tape could not just replace those lines as you did with the reader was fast (or so it seemed at the time), reading cards; you had to punch a whole new tape. Hence, edit- 300 characters per second. The punch was consider- ing on the Flexowriter was a painstaking process of ably slower at 20 characters per second. The console de- reading an existing source tape and simultaneously vice was an office-style electric typewriter that had been punching a new one, while stopping at each point interfaced to the PDP-1 for character-at-a-time input where changes were to be made to type new material and output. and skip over unwanted old material. The PDP-1 was the first computer built and sold by It was also possible to edit on the computer, which DEC and thus the leading edge of the minicomputer is what we did while debugging and recompiling dur- revolution. It was anything but ‘‘mini’’ by today’s stan- ing our slots of computer time. The editor on the dards, however; it occupied several tall cabinets in its PDP-1 had a simple line-oriented interface that let minimum configuration. All that, and it had a main users step through an existing paper tape, adding or memory of only 4,096 18-bit words (effectively 8 replacing lines to produce a new generation of the Kbytes). This was core memory made of tiny magnetic source. Using this editor consumed precious com- toroids strung on thin wires in a 3D mesh. It had a puter time, however, and it used the whole computer cycle time of 5 microseconds. The processor executed to do a ‘‘simple’’ task, so it was known as Expensive most instructions in two cycles (10 microseconds)—one Typewriter. cycle to fetch the instruction from memory, and the That could only add, delete, or second to load and/or store the memory operand. replace entire lines of text annoyed me considerably. It Some instructions did not reference memory and so was a bothersome fact of punched cards that making required only one cycle. any change on a line required retyping that whole All this notwithstanding, it was exciting to actually line on a new card, and I didn’t see why that limitation be able to sit at the console and use the computer inter- needed to exist for this new medium where there was actively. My prior experience was with mainframe class no physical separation between one line and the next machines like the IBM 709 or 7090. Those required pre- other than the carriage-return character. paring a program on punched cards, submitting the deck to the computer center for a batch run, and get- The birth of TECO ting a paper listing of the results the next day. With Thus, I decided to write a program that, like Ex- the PDP-1, the code-compile-debug cycle was shortened pensive Typewriter, would let me copy a paper tape

110 IEEE Annals of the History of Computing Published by the IEEE Computer Society 1058-6180/09/$26.00 c 2009 IEEE [3B2-8] man2009040110.3d 31/10/09 18:24 Page 111

while making changes along the way and Although quite interactive, TECO was not would let me make those changes character a screen editor at this point. Although our by character. Accordingly, the first few PDP-1 did have a CRT display device, neither commands would include these types of theparadigmnorthecodeexistedfordis- functions: playing text. Hence, source was kept on paper printouts, and editing online meant delete a character, looking at a few lines at a time typed out delete a line (it was still convenient to on paper. work on lines sometimes), With interactive editing, a number of insert text (any amount from one charac- other enhancements were soon required. It ter to multiple lines), and quickly became clear that moving through search for text at the point where you a source tape in only one direction was still wanted to make changes. awkward. An especially easy, but painful mis- take would be to mistype a search command TECO was not initially intended to be an so that the text you wanted would not be interactive, online editor. Because of the scar- found and the copying would continue to city of computer time, online editing was still the end of the tape. To solve this problem, I considered somewhat squanderous, and we decided it would make sense to read a really did not want to wait until our next chunk of the source into memory where a time slot to get the next source revision number of edits could be made before com- ready. mitting it to the new paper tape. The natural Therefore, TECO was intended to be used unit for this was one typewritten page. Most offline, on the Flexowriter, where we would sources were paginated to this size because prepare a separate paper tape with the com- we were using letter-size fanfold paper stock mands needed to edit our existing source in the Flexowriters and console typewriter. tape. As people often say, ‘‘it seemed like a This was a big help. The usual search was good idea at the time.’’ In other words, the limited to the current page, so a failed search idea was to hand-mark changes on your was no problem. Just go back to the top of source listing and enter the TECO com- the page and try again. Plus, we could make mands necessary to make those changes on some changes, see how they looked, and if the Flexowriter (i.e. find a spot, delete, in- still not right, do some further edits. sert, move on). Then, when our computer Page-at-a-time editing required new com- time came, we would load TECO and read mands for keeping track of the location that in our commands tape, so TECO could editing would take place (the point), for mov- read our old source tape and quickly ing to the next page or to the end of the tape, punch a new one. and for searching that was not limited to the Hence, in the beginning, TECO was a lan- current page. This search still carried the risk guage for describing changes to a source pro- of going too far, but since it was used less gram or, more generally, a stream of text. often and only to get you to the right page, This turned out to be its real power as time that risk was much lower. passed and its evolution continued. Youmightask,whyonlyonepageata time? Why not read in the whole source TECO becomes interactive tape? As I noted earlier, our PDP-1 had a In the short term, however, offline com- total memory component of about 8 Kbytes, mand preparation proved to be impractical. and that had to hold the entire TECO pro- It was impossible for most ordinary mortals, gram as well as whatever text was being myself included, to consistently prepare edited. It was not until many years later command tapes that would work right. Like that memories became large enough that any other program, they would have bugs yanking in the whole file became practical that would only becomeevidentwhileon and routine. the computer. Thus, I added a mode to One enhancement in that direction be- TECOearlyonthatwoulddispensewith came possible when the RLE PDP-1 had a reading the command tape first and simply swapping drum added to it. Although this de- let us enter commands at the console type- vice was not large enough to serve as perma- writer. Needless to say, this was an entirely nent storage for programs or sources, it was different experience. We could enter one or fast and could be used to work around the a few commands, make sure the result was limited main memory size. For TECO, I right, and then move on. implemented a kind of paging mechanism

October–December 2009 111 [3B2-8] man2009040110.3d 31/10/09 18:24 Page 112

Anecdotes

Alleged Patent Infringement As simple as it seemed, even at the time, this method search for prior art. One of the issues was character- of command processing became the subject of a patent based command dispatching, and somehow, IBM infringement case some years later. This was in the late found TECO, which was originally implemented years 1980s, and I was working for DEC in the VAX/VMS before the claims of this challenger. IBM identified me group. One day, I got a call from someone in the DEC as the original implementer, traced me to DEC, and legal office. It seems that IBM was being sued by contacted the DEC legal department to ask for assis- some small company because of alleged patent in- tance. I consulted with some IBM attorneys and was fringement by the IBM PC. Some basic programming looking forward to a full-blown trial. I never got the techniques were asserted as patented IP by this com- call though, so I presume the case was settled well pany, and in looking to defend itself, IBM had done a short of that.

that allowed the main editing buffer to be was the DDT debugger,3 and it had a set of many times larger than could fit in memory. single-letter commands with numeric argu- I would draw on some of these paging ideas a ments preceding. For example, to examine few years later in the implementation of location 123 in your program, you would other multiuser systems culminating in type 123/.DDTwouldactimmediatelyon TENEX and TOPS-20.1,2 the slash and print the contents, so the line Punched paper tape remained in common would then appear as 123/ lac foo.TECOfol- use through at least the late 1960s on a num- lowed that form with commands such as ber of systems, but TECO supported other media almost as soon as it became available 5d, meaning delete five characters; on any machine we used. One of the other 3c, meaning move forward three char- PDP-1s at MIT had a magnetic tape drive, acters; and I quickly added a magtape driver to 10l, meaning move forward 10 lines; TECO. Again, there was no operating system, 2k, meaning kill (delete) two lines; and or even common I/O libraries at that time, so iTEXT, meaning insert ‘‘TEXT,’’ or each program had separate commands and everything from the initial i to the special I/O routines added for each device. text termination character. Magtape was never practical for program storage, of course, even though it was won- As I noted earlier, I based the initial design derfully fast compared to paper tape. Much of the TECO commands on entering them better was DECtape (or MicroTape), the offline,buttheycontinuedtoworkwell block-addressable small-reel tape system when interactive use became the rule. (See eventually added to the PDP-1 and available the sidebar for an interesting side note on on all DEC systems for many years. DECtape character-based command dispatching.) had a basic file system that supported a mod- From that relatively simple start, I went on est number of named files on each reel and to add further enhancements. Some of them the ability to rewrite files any number of were around making the language more con- times. This required TECO to grow the ability sistent and general. For example, we did not to open a file by name, not just yank a stream need a separate command to move the from a serial input device. pointer in reverse (the original r command); Even when timesharing and disk-based a negative argument to the character-move- file systems came into common use, TECO forward command was quite natural. The editing continued to be a page at a time for same applied to commands that operated the most part. Conservative memory use on lines—-3l meant move backward three was still important, and for all its power, lines, and -5k meant kill the preceding five TECO was economical to run. lines. 0 (zero) meant the current line, so 0l meant to move to the beginning of the cur- The TECO language rent line. A number of simple constructs I did not give much thought to the quicklybecameahabitforanyTECOuser, TECO’s ‘‘human interface’’ design at the be- such as using 0kk to kill all the current line ginning. The concept really didn’t exist regardless of where the pointer is on it. around program tools at that point. The (TECO uses the convention that the default most commonly used interactive program argument is 1 for most commands.)

112 IEEE Annals of the History of Computing [3B2-8] man2009040110.3d 31/10/09 18:24 Page 113

TECO becomes a add a comment at the end.’’ This gave rise By late 1962, TECO had about the level of to the original loop construct: ( commands capabilities that simple editors would have boolean ; commands ). for years to come, but TECO’s development The loop would be executed zero or more didn’t stop there. Many of the subsequent times until the test was false. A search variant enhancements were done simply because was available that returned true only if the something occurred to me that I could easily text was found, so search and modify loops do or someone suggested something, and it were straightforward. The loop-begin and seemed like a cool idea. Our mindset was loop-end commands appeared as parentheses that cool ideas were fun to pursue, even if with a dot in the middle on the PDP-1. Sub- we couldn’t think of a practical use or need sequent ASCII-based versions of TECO used right away. angle brackets for this purpose. More significant additions—the ones that Integer variables were also added around begantogiveTECOsomepowerasapro- this time, again from the single-letter set a–z, gramming language or text engine—included 0–9. u (use) would store its argument into text buffers and the looping construct. TECO the variable, and q (quantity) would stand handled simple program modification fairly as the stored value in an expression. The well at that point, but it did not offer a way same variable name could have both a text to do significant restructuring (e.g., move a and numeric value; the command deter- sizeable amount of text from one place to an- mined which was being referenced. Because other or replicate a segment of text a number simple arithmetic expression were accepted, of times). To provide this, I added the con- a loop to run, say, five times could be writ- cept of text variables—that is, a variable ten as that would hold an arbitrary section of text. 5ua The command to move a range of text into ( qa; commands qa-1ua ) a text variable was x. (I was running low on unused letters by then.) Its prefix argu- Spaces and line breaks were not syntacti- ment(s) identified a range of text in the cally significant. As this simple quasi-example buffer in the same way as the k command, shows, TECO was nothing if not terse. Fairly and the single letter following the x was the complex loops and other command sequen- variable name from the set a–z, 0–9. g (get) ces could be written in TECO, and mostly was used to copy the contents of a text vari- looked like line noise. TECO was one of able into the main buffer at the editing the first languages to spawn the practice of point and could be used any number of handing someone a one-line string of near times to replicate copes of the text. Despite gibberish and asking with a grin, ‘‘tell me the lack of a mnemonic association for x,it what it does.’’ Nonetheless, TECO made it quickly came to seem natural, almost intu- onto Jean Sammet’s list of known program- itive. To x something became as easily spo- ming languages sometime in the late ken and understood by TECO users as 1960s.4 ‘‘store’’ would have been. There have been innumerable comments Then, given that we had the ability to store over the years about how obscure the TECO any text in a variable, I implemented a com- language is. Few would dispute the premise mand to execute a text variable as a TECO that it is easier to write than to read. As an - command string. An optional argument itor however, its brevity was one of its advan- could be given in the form of a preceding ex- tages. Regular users quickly learned the more pression. Thus, TECO came to have a form of frequent command sequences and did not or callable function, and it followed even need to think about them. Especially from the original concept that a concise after WYSIWYG editors became common, string of text would represent commands to the claim that ordinary users could only modify other text. handle verbose, line-oriented editors disap- Around that same time, I also found that I peared. This was hotly debated within DEC wanted to be able to make repetitive and sys- for some years, pitting developers against tematic changes to the source text. This the business and marketing folks. Today, if included simple cases like changing all occur- we considers all the obscure keystroke rences of ‘‘foo’’ to ‘‘fie’’ (which would later be sequences available in the most commonly supported by the replace command) and used software, with modifiers Control, things beyond simple search and replace, Alt, Shift, and others, TECO seems almost such as ‘‘find every line with ‘foo’ in it and simple.

October–December 2009 113 [3B2-8] man2009040110.3d 31/10/09 18:24 Page 114

Anecdotes

TECO moves to new machines most complex version of TECO ever in com- Within a few months, TECO was being used mon use. Although there were numerous in several PDP-1s around MIT. Besides the first other ports for other machines in the follow- oneinRLE,therewasonebeingusedforanal- ing years, most of them were much more ysis of bubble chamber photographs by Profes- basic and similar to the PDP-1 version. Even sor Martin Deutsch. In my last undergraduate the version of TECO included by DEC in its year or so, Deutsch hired me to do further initial release of the PDP-10 (DecSystem-10) work on TECO and some other programming was more basic. Bob Clements (at DEC at tools that I had developed. the time) had taken a relatively early version A PDP-1 had also been installed in the new of the PDP-6 AI TECO, stripped it down to re- Tech Square building where Marvin Minsky move things that were not available on most had his AI lab. This was also where the first installations (e.g., the expensive CRT display) DEC PDP-6 at MIT would be installed in or to timesharing terminal users, and that be- 1965, and it become the first machine to came the version shipped by DEC on the which TECO would be ported. I did not do PDP-10 and later PDP-6 installations. It was that port myself; it was done by Stewart Nel- also the version that came into my hands son, Richard Greenblatt, and Jack Holloway, when Bolt Beranek & Newman (BBN) got a who had been using the AI PDP-1 and were PDP-10 (1969), which I would evolve from among the first to get their hands on the then through about 1986. new PDP-6. Some enhancements had already been made to the PDP-1 version by the AI The Spirit of Open Source group, and it was used heavily there. Hence, From the time of TECO’s original develop- porting it to the new PDP-6 was an urgent ment through the PDP-6 port, we were all project. I had earlier been offered a part- happy to have DEC or anyone else take the time job by DEC to do that port for their programs we had written to use or even sell. new, still-in-development machine, but I For an undergraduate like myself, having peo- was trying to finish my senior year without ple use and like them was the reward. Besides, flunking out, so wisely I declined. nobody had any idea how or whether soft- PDP-1 TECO was written in assembly lan- ware could be copyrighted or otherwise pro- guage, and simply recompiling the source, tected. This was the open-source model in even with a few edits, was impossible. How- action long before that term came into use. ever, the PDP-6 had a far more powerful and Starting with the PDP-6, TECO was general instruction set, so much of TECO included in the base software set of every sys- could be simply (if only manually) translated tem that DEC offered, including the PDP-8, instruction by instruction while still remain- PDP-11, DecSystems 10 and 20, and VAX/ ing in assembly language. One big difference VMS. It also continued to be heavily used was the change of character set. The PDP-1 and enhanced by the hackers5 in Minsky’s used an encoding called FIO-DEC (the Frie- AI lab, eventually including Richard Stall- den paper tape code as adopted by DEC). man. In the early to mid-1970s, Stallman The PDP-6 used a Teletype Model 35 or 33, would make some key enhancements to which supported ASCII (upper-case only). TECO that allowed it to become a fully inter- Another enhancement begun in the AI PDP- active, WYSIWYG-style onscreen editor. A 1 TECO and made fundamental on the PDP-6 key piece of this implementation was an en- was to use the display to show the text around hancement where an individual keystroke the editing point. This was not yet on-screen couldbemadetoimmediatelyinvokea editing in the current sense; commands were macro (i.e., a function to be executed). This still entered and echoed on the console tele- included the normal graphic keys, so typing type, but the feedback to the user was much an a in normal text entry mode invoked a enhanced. It wasn’t until some years later function to insert a into the buffer and, of that CRT-based terminals became common. course, update the onscreen display. This Until then, most users could only use TECO resulted in many users creating keystroke- in the traditional way on a hard-copy device. triggered editing operations, and before Many other enhancements were made in long, an effort was made to collect the most the next few years, fostered by the PDP-6’s useful of them into a set that could be docu- much larger memory, greater power, and pro- mented and used by others. This became the gramming ease. The command set for that original Editor Macros (). version can still be found with a Web search TECO would continue to be the text en- today and, as far as I know, was by far the gine for EMACS for several years, but it was

114 IEEE Annals of the History of Computing [3B2-8] man2009040110.3d 31/10/09 18:24 Page 115

ultimately replaced by a Lisp-like text manip- References and notes ulation language known as Emacs-Lisp. 1. D.G. Bobrow et al., ‘‘TENEX: A Paged Time Several versions of TECO for soft-copy ter- Sharing System for the PDP-10,’’ Comm. ACM, minals would also be done, including one by vol. 15, no. 3, 1972, pp. 135–143. me called VTECO for TENEX and TOPS-20. A 2. See Dan Murphy’s TENEX and TOPS-20 papers number of dialects of the TECO command at http://tenex.opost.com/ language also grew up, as various branches 3. DDT originally stood for ‘‘DEC Debugging of development and evolution continued in Tape’’ as, like all programs for the PDP-1, it was different places. The DEC Users Group loaded from a paper tape. DEC later changed (DECUS) had a TECO Special Interest Group that to ‘‘Dynamic Debugging Technique’’ as (TECO-SIG). Although DEC products contin- paper tape faded away. ued to be where TECO was most consistently 4. Jean Sammet’s list appeared periodically in the available and used, it was ported to many Comm. of the ACM (see vol. 19, no. 12, 1976). other products as well. The lineage of many 5. S. Levy, Hackers: Heroes of the Computer Revolu- of these versions is now difficult or impossi- tion, Doubleday, 1984. ble to determine. 6. Two good places to find them are http://almy.us/ teco.html and the Wikipedia article on TECO at Reflections http://en.wikipedia.org/wiki/Text_Editor_and_ Clearly, TECO has had numerous users Corrector. over the years. A relative few wrote or attempted to write actual programs in Readers may contact Dan Murphy at dan. TECO. One of my early exercises was to [email protected]. write an arithmetic expression compiler in Contact department editor David Walden at annals- TECO. This would take an expression like [email protected]. x ¼ a þ (b c)*3/d and translate it to a se- quence of PDP-1 assembler instruction to per- form the computation. I never attempted to make it a practical compiler though; it was mainly a way to test the completeness of the TECO command set and a cool hack. Other known TECO programs included an early email interface—a set of TECO macros from Larry Roberts at ARPA that let you selec- tively read messages from your email inbox. Although this level of TECO hacking was unusual, many users would come up with their own customizations in the form of handy command sequences that could be saved as TECO macros and quickly invoked in an ordinary editing session. Unlike the keystroke captures in some of today’s edi- tors, TECO macros were plain text, so they couldbeeditedlikeanyothertextto debug and enhance them. With that and the ability to use programming constructs like loops and conditional searches at any time, TECO offered capabilities that many former TECO users, myself included, find lacking in contemporary editors. Things I used to do in TECO on the fly must now be done more laboriously, or if that isn’t tolera- ble, not done in the editor at all but rather using other tools such as Grep, Sed, Awk, and Perl. For anyone who would like to run TECO now, at least occasionally, there are versions available on the Web for most common systems.6

October–December 2009 115