View text source at Wikipedia
Paradigm | general-purpose macro processor |
---|---|
Designed by | Calvin Mooers |
First appeared | 1964 |
Stable release | |
Influenced by | |
Macro SAP[3] | |
Influenced | |
SAM76, ML/I[3] |
TRAC (for Text Reckoning And Compiling) Language is a programming language developed between 1959–1964 by Calvin Mooers and first implemented on the PDP-1 in 1964 by L. Peter Deutsch.[4] It was one of three "first languages" recommended by Ted Nelson in Computer Lib. TRAC T64 was used until at least 1984, when Mooers updated it to TRAC T84.[4]
TRAC is a purely text-based language — a kind of macro language. Unlike traditional ad hoc macro languages of the time, such as those found in assemblers, TRAC is well planned, consistent, and in many senses complete[fact or opinion?]. It has explicit input and output operators, unlike the typical implicit I/O at the outermost macro level, which makes it simultaneously simpler and more versatile[vague] than older macro languages.
TRAC is a text-processing language,[5] also called a string processing language.[6] Because of this the only data type available is a string of characters. Numbers are strings of digits, with integer arithmetic (without specific limits on maximum values) being provided through built-in ("primitive") functions which operate on their string representation. Arguably, one aspect of its completeness is that the concept of an error is limited to events like lack of file space and requesting expansion of a string longer than the interpreter's working storage; what would in many languages be described as illegal operations are dealt with in TRAC by defining a result (often a null string) for every possible combination of a function's argument strings.
TRAC is, like APL or LISP, an expression oriented language (in contrast to more typical procedure-oriented languages) but, unlike APL, it completely lacks operators. In most respects, it is a case of pure functional programming. It has, in common with LISP, a syntax that generally involves the presence of many levels of nested parentheses.
TRAC is homoiconic: that is, a TRAC program can be represented and manipulated within the TRAC language itself.[7][8][9] The emphasis on strings as the single data type is so strong that TRAC provides mechanisms for handling the language's own syntactic characters either in their syntactic roles or like any other character, and self-modifying code has more the feel of a natural consequence of typical TRAC programming techniques than of being a special feature.
The main inspiration for TRAC came from three papers by Douglas McIlroy.[7][10][11][12]
Mooers trademarked the name TRAC in an effort to maintain his control over the definition of the language, an unusual and pioneering action at the time. At one point, he brought an intellectual property infringement suit against DEC, alleging that a contract to deliver a mini-computer with a TRAC interpreter violated his rights. "The first issue of Dr. Dobb's Journal, one of the early publications in the personal computer field, has a vitriolic editorial against Mooers and his rapacity in trying to charge people for his computing language."[13][14] The name has since been used several times for unrelated information technology projects, including a current open source project management system called Trac.
TRAC was later implemented on the PDP-8, PDP-10, and PDP-11.
There have been various languages inspired by TRAC. To avoid any trouble with Mooers, they renamed primitives and/or used different metacharacters. In SAM76's case, primitives were added, according to Claude Kagan, "because TRAC is baby talk". In MINT's case, primitives were added to give access to a sophisticated text editor machinery.
TRAC was used by FTP Software in its PC/TCP product as the modem dialer scripting language.
TRAC was also used as a front end on Digital Productions Cray renderer for films, including The Last Starfighter.
This is an example of a simple program that asks the user's name and exits, written in TRAC T64:[17]
#(DS,PROG.A,( #(PS,(WHAT IS YOUR NAME? )) #(DS,NAME,##(RS)) #(PS,( GOODBYE)) ))'
TRAC T84 uses a slightly different syntax and different names for its primitives. The following is a script to compute Fibonacci numbers, written in TRAC T84:[18]
:(s,fibo,( :(ei,<1>, 1, 0,( :(ei,<1>, 2, 1,( :(aa, :(ri,fibo,:(as, <1>,1)),:(ri,fibo,:(as, <1>,2))) )) )) ))` :(mw,fibo)'