Oldest files meme: PSCom

Saturday 3 January 2009

James shows his oldest files, a meme he picked up from Doug who got it from Brandon, its creator.

See one of the above posts for details, but the idea is to find the oldest file in your home directory tree, and tell its story.

I found these:

1986-08-20 .\pscom\avl.h
1986-08-20 .\pscom\avl.c

(full files: avl.h and avl.c)

PSCom was a PostScript preprocessor that I wrote while employed at Digital. We wrote a lot of PostScript code, and wanted to be able to use conditional inclusion, macro replacement, and lexical compression (similar to what jsmin does for JavaScript today). PSCom was the result. It’s a C program, and I’m amazed to remember the amount of work that went into providing basic features we take for granted now in the Python world, and in any modern programming environment.

avl.c starts like this:

/***
 *** avl.c --
 ***
 *** The AVL height-balanced tree abstraction.
 *** Six functions are defined:
 ***
 *** newavl()
 *** returns an empty avl tree.
 *** addnode(tree, key, data, compare)
 *** Adds a new node to the tree given.
 *** node = findnode(tree, key, compare)
 *** Finds the node in the tree.
 *** modnode(tree, key, data, compare)
 *** Modify an existing node.
 *** im = startiter(tree)
 *** Starts an iteration over the nodes, returning an
 *** iteration map.
 *** im = nextnode(tree, im, &node)
 *** Returns the new map, and writes a pointer to the next
 *** node.
 *** size = avlsize(tree)
 *** Returns the number of nodes in the tree.
 ***
 *** N.Batchelder, 5/7/85.
 *** Adapted 1/13/85.
 ***/

Clearly this would simply be a dictionary today, but I had to go and write an entire data structure to be able to store the symbol table for PSCom. The adapted date must be a typo, it was adapted 1/13/86, based on the comment in avl.h If it was truly begun in May of 1985, then it was originally part of a different project, perhaps a PostScript-like language implementation I was working on while at Penn.

One odd feature of PSCom: when shortening identifiers, you could choose the set of characters that would be used. PostScript has very lenient rules regarding allowable characters in identifiers, so you could use -_= as the set to choose from, and end up with a final file that looked like hardware timing diagrams, or ,.:;’ which would be indistinguishable from chicken scratch.

One thing about the code that strikes me now: I wrote a lot of comments back then! I should get back into that habit...

» 2 reactions

Comments

[gravatar]
Jan 11:05 AM on 4 Jan 2009

Nice one, Ned — The link to avl.c is broken or you forgot to upload the file :)

[gravatar]
Ned Batchelder 12:00 PM on 4 Jan 2009

@Jan: sorry! Turns out this was the very first .c file I've ever tried to upload, so I had to add it to the list of uploadable file types!

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.