Saturday, January 27, 2007

Pascal is for Poets

That motto, "Pascal is for Poets" once adorned a T-shirt belonging to a colleague of mine at Georgia Tech by the name of Gus Baird. I had recently started work at the Research Institute there, and in addition to doing design and coding work on an Army intelligence system designed the ANUYK-71 (known affectionately to us as Micro-Fix), I had the good fortune to be assigned to assist Prof. Baird in teaching a class in Pascal to the 82nd Airborne at Ft. Bragg, North Carolina in the early 80's.

"What will I be doing?", I asked Ed Shanahan, my supervisor at GTRI.

"Just help set up the computers and keep them running," he answered. "You'll probably need to help the students with their lab work."

"Sounds easy enough," I said. "I've had plenty of practice doing that during my VA work-study program days. Do you really think Gus can teach a bunch of Army folks how to program in Pascal in just a week?"

"I hope so," Ed said, "That's what they are paying us to do. All of the people they are sending are supposed to have prior computer experience, so it should be possible."

Ed, Gus, a couple of Tech student assistants, and I met in a hotel outside Ft. Bragg on the Sunday prior to the first day of the new class. Ed and Gus had just gotten back from a meeting on the base, and they were obviously not happy. Apparently, the Army had not, in fact, sent all people with prior computer experience, but about half the class had never even touched a computer before. Mind you, this was 1982, and that was still the norm for most of society.

"There has been a change of plans," Ed said looking at me. "We'll have to divide the class in half, and you'll be teaching the people with no prior experience. Gus will continue as planned so that the experienced people get what the government paid for."

"Meanwhile, ten hours from now, I'll be lecturing to a bunch of malcontents who probably didn't even ask to be sent to this class, for eight hours a day for five days without a lesson plan," I pointed out.

"That's about the size of it," Ed laughed. "We figure you'll be lucky to be able to teach them how to turn it on in a week."

After a restless night, I found myself in front of a varied group of uniformed individuals. They were initially well behaved until the Captain who was in charge of the educational center left. Then, as I began the first tentative attempts at introducing them to fundamental computer principles, the heckling began. Some of the students had been sent to the class under a time-honored Army tradition of sending those who would be least missed. Some of them knew this, and resented it and the fact that they had been immediately put in the "dummies" group.

Somehow I got though that first day. The second day was better; with most of the basic concepts of computing like binary arithmetic, boolean logic, and the Von Neumann architecture having already been covered, the students seemed glad to begin learning the UCSD Pascal language that was available on the Apple II. Surprisingly, it didn't take long to cover the entire language. Pascal is, after all, designed to be a small and easy to teach language, the number of reserved words being less than 40 in most implementations.

I found that the trick to holding the students interest was to keep it real. I had to be able to point to something useful that the Apple II could be made to do by each person in the class by Friday. The answer was something that was not readily available in the early days, a database. Most people can think of some part of their daily work that could be made easier if only they had a custom database to automate it, and my "sweat-hogs" were no exception.

In the next classroom, Prof. Gus Baird was giving the experienced people the full university level course in Pascal, albeit somewhat abridged. From our combined lab sessions, I gathered some of them were having a tough go of it. I believe the expression we used was "a sip from the fire hose." I never had the opportunity to sit in on one of Gus's classes, but I gather he was very knowledgeable, focused, and quite entertaining. His background of writing weapons guidance software had given him a lot of interesting stories, an appreciation for attention to detail, and a low tolerance for error prone programming habits. To him, Pascal code done right was poetry.

Meanwhile, my students were learning the basics of Input/Output using text and then binary methods. The Bell-and-Howell "Black" Apple II computers that the Army had acquired, by the clever trick of using education funds to circumvent the usual Army bureaucracy, had floppy disk drives, which made them as powerful as most small computers of the time. We quickly moved on to searching and sorting techniques, and finally user interface design. Before I knew it, Friday had come and it was time for them to take the final exam that was required to get a training certificate. Nearly three quarters of the class managed to pass the final exam.

Like others who have had the opportunity to teach, I sometimes wonder what my students did when they left the class. Did any of them go back to their posts, clutching their own floppy disk full of database source code, and create wonderful automations, and then go on to become professional programmers? Did it seem as miraculous to them as it did to me that it was possible to learn so much in such a short time? When I think back on it now, it seem hard for me to believe what can be accomplished when you don't know what can't be done.

If any of those students did go on to study programming at a university, they surely found it to be a far different experience. You can't take an advanced programming course until you have had an introductory programming course, and you can't take the intro until you have met the prerequisites. It may take a full year before they are allowed to get back to the level of that Friday. At some universities I know, they may never get beyond that basic level.

Strange as this tale sounds in these times, it wasn't unusual then. Many others tell the same story of how quickly even middle school students respond to teaching programming rather than "using computers" as we do today, and of how empowering it is to both teach and learn to take control of the computer with our own hands. We have lost the simple innocence of those early microcomputer years, mired in the complexity of modern layered software where, far from controlling the machine, you are controlled by it.

Friday, January 26, 2007

What The World Needs is More Neal Stephensons

"When you are wrestling for possession of a sword, the man with the handle always wins." Neal Stephenson in Snow Crash.

In addition to the many incredible books that Neal Stephenson has written, including Snow Crash, Cryptonomicon, The Diamond Age, and the three novels in the Baroque Cycle, he has also written an essay called "In the beginning was the command line" that is available on the web. It is worth the read. There are also several web interviews: A Conversation With Neal Stephenson, Slashdot's Neal Stephenson Responds With Wit and Humor, and the Salon.com Interview.

Calls for an Open Source Hall of Fame

A blog called Software as She's Developed called two years ago for an open source hall of fame. No nominations appear to have been made, but clearly Michael Mahemoff, a London-based freelancer and author of Ajax Design Patterns is a kindred spirit. So let's pick up the torch and run with it!

No Rhyme or Reason

Art in the blood is liable to take the strangest forms. Sherlock Holmes

Back in the day, around 1980 or so, there was a magazine called Omni. It was like the Wired of its day with lots of strange and wonderful things, but that's a subject for another day. What I want to talk about today is the Omni science limerick contest. They intended to publish the top ten or so best limericks on the subject of science and give a grand prize which I've forgotten. Anyhow, I composed some limericks for this contest, which I never submitted, and consequently I never won. So without further ado....

By the limerick bug I was bitten

and though I wrote it all at one sittin'
I tucked it away
until today
when I finally showed off what I'd written

Not some people might say that its terse
while others might even say worse
but in spite of the facts
and all that it lacks
I present my biological verse.


If amoebas are hard to envision
reproducing by cellular fission
the professors might bray
but its simpler to say
that they multiply by division

And now the second masterpiece...

There was a young fellow named Prince
whose gravitational field was intense
he collapsed on his soul
and became a black hole
on the subject of matter, he was dense

If there are any former editors of Omni out there, let me down easy, OK?



Thursday, January 25, 2007

War and Peace

“To the man who loves art for its own sake,” remarked Sherlock Homes, tossing aside the advertisement sheet of the Daily Telegraph, ”it is frequently in its least important and lowliest manifestations that the keenest pleasure is to be derived.”

It is scarcely news that the literature of programming has become somewhat dumbed down in the last decade or so. In the bookstore, "Programming for the complete idiot" sits alongside "Learn Visual C++ 9.7 in 8 hours or less." And the state of computer magazines is also a joke with a few articles, mostly reviews, of less than two pages scattered amongst a liter of advertisements for a total page count of less than a hundred. I guess, to be fair, they have to compete with the internet.

Well, for anyone who might not be old enough to remember, I'm here to tell you the state of the computer press was not always so drear. There are still many wonderful books on computer science (such as Algorithms + Data Structures = Programs by Niklaus Wirth), but you won't find many of them on the shelves of your local bookstore, and many are out of print. Computer magazines, however, are all but gone. What remains is but the shell of their former selves. I exaggerate, you say? Let me just reach down into the depths of my archive and see what I can find. Hmm, how about a September 1981 copy of Byte (the small systems) Magazine?

A quick check of the page count gives 496. That's four hundred and-ninety six count 'em, pages. The theme of this particular issue is Artificial Intelligence. There are 13 articles, 6 reviews, and 18 other pieces under the heading of Nucleus. Some of the more impressive titles include:

Tree Searching, Part 1: Basic Techniques by Gregg Williams,
One Step Forward - Three Steps Backup, Computing in the US Space Program by Patric Stakem,
Artificial Intelligence
by Steven K Roberts,
Symbolic Differentiation á la LISP
by Ronald L Nicol,
Knowledge-Based Expert Systems Come of Age
by Richard O Duda and John G Gaschnig,
The Atari Tutorial, Part 1: The Display List
by Cris Crawford,
Natural-Language Processing, The Field in Perspective
by Gary Hendrix and Earl Sacerdoti,
and The Emperor's Old Clothes" by Charles Antony Richard Hoare.

Need I say more. Oh, and in case you are wondering, the cover shows a picture of a small computer presumably using a tv camera to read that heaviest of literary classics, Tolstoy's War and Peace.

The Mobius Strip

“Chance has put in our way a most singular and whimsical problem, and its solution is its own reward.” Sherlock Holmes.

Mob Software: The Erotic Life of Code, An Essay in First Person by Richard P. Gabriel & Ron Goldman writes a new chapter in the continuing open-source software saga that began with The Cathedral and the Bazaar . Both are fascinating reads and highly recommend, but I want to remunerate on a bit of etymology relating to the essay. In it they quote the Oxford English dictionary definition of mob as, "A multitude or aggregation of persons regarded as not individually important."

They then deliver the central message: "...We know how to produce small portions of software using small development teams—up to 10 or so—but we don’t know how to make software any larger except by accident or by rough trial and error. ... The way out of this predicament is this simple: Set up a fairly clear architectural direction, produce a decent first cut at some of the functionality, let loose the source code, and then turn it over to a mob."

I was stuck by how apropos the word mob seemed in this context. I recalled reading in one of Neal Stephenson's Baroque Cycle books, probably The System of the World, that the origin of the word mob is a shortening form of "mobility" and was first used in a kind of play on words as the opposite of "nobility." A London aristocrat was publicly decrying the rise of a new class of interloping vagabonds who dared to come and go as they pleased, apprenticed to no one, earning their bread wherever they could find work in the new economy.

Sound familiar? It could be an precursor of the post-dot-com practice of programmers finding work via the web on whatever projects that interest them, and getting by, just fine thank you.

Programming as poetry

I just finished Scott Rosenberg's new book Dreaming in Code and it has inspired me to start this blog. There are many inspiring things in the book, but one of the concepts that really stood out was in the chapter titled "Engineers and Artists." It is Richard Gabriel's concept of "programming as literature." Gabriel is a Distinguished Engineer at Sun, and the core of his idea is that we should train developers the way creative writers, poets, or artists are trained - by studying the great works in their field. There is just one thing that has been holding us back from doing this, and that is that most of the great (or at least good) works of software are proprietary closed source.

Well, as you might have noticed, in the last few years the internet, search engines, and the Open Source movement have made the source to hundreds of programs available to anyone interested enough to seek them out. All we need to do to bring Richard's goal within our grasp is to list some examples of code that teaches good programming practices. That will be the overarching goal of this blog, to seek out new source archives, and to boldly code where no one had code before.

Wednesday, January 24, 2007

Rhyme of the Ancient Programmer

The following poem is one of the oldest examples
(although I'm sure there are older) that I have found
of poetry about software.

Only LISP Can Make a Tree


I think that I shall never see
A matrix lovely as a tree.
Trees are fifty times as fun
As structures a la PL/I
(Which Dijkstra claims are too baroque).
And SNOBOL's strings just can't compare
With all the leaves a tree may bear.
And COMIT strings are just a joke.
Vectors, tuples too, are nice,
But haven't the impressive flair
Of trees to which a LISP is heir.
A LISPer's life is paradise!

Many people think that JOSS
And others, too, are strictly boss;
And there are many BASIC fans
Who think their favorite language spans
All that would a user please.
Compared to LISP they're all a loss,
For none of them gives all the ease
With which a LISP builds moby trees.

RPG is just a nurd
(As you no doubt have often heard);
The record layouts are absurd,
And numbers packed in decimal form
Will never fit a base-two word
Without a veritable storm
Of gross conversions fro and to
With them arithmetic to do.
And one must allocate the field
Correct arithmetic to yield,
And decimal places represent
Truncation loss to circumvent:
Thus RPG is second-rate.
In LISP one needn't allocate
(That boon alone is heaven-sent!)
The scheme is sheer simplicity:
A number's just another tree.
When numbers threaten overflow
LISP makes the number tree to grow,
Extending its significance
With classic treelike elegance.
A LISP can generate reports,
Create a file, do chains and sorts;
But one thing you will never see
Is moby trees in RPG.

One thing the average language lacks
Is programmed use of push-down stacks.
But LISP provides this feature free:
A stack - you guessed it - is a tree.
An empty stack is simply NIL.
In order, then, the stack to fill
A CONS will push things on the top;
To empty it, a CDR will
Behave exactly like a pop.
A simple CAR will get you back
The last thing you pushed on the stack;
An empty stack's detectable
By testing with the function NULL.
Thus even should a LISPer lose
With PROGs and GOs, RETURNs and DOs,
He need his mind not overtax
To implement recursive hacks:
He'll utilize this clever ruse
Of using trees as moby stacks.
Some claim this method is too slow
Because it uses CONS so much
And thus requires the GC touch;
It has one big advantage, though:
You needn't fear for overflow.
Since LISP allows its trees to grow,
Stacks can to any limits go.

COBOL input is a shame:
The implementors play a game
That no two versions are the same.
And rocky is the FORTRAN road
One's alpha input to decode:
The FORMAT statement is to blame,
But on the user falls the load.
And FOCAL input's just a farce;
But all LISP input comes pre-parsed!
(The input reader gets its fame
By getting storage for each node
From lists of free words scattered sparse.
It parses all the input strings
With aid of mystic mutterings;
From dots and strange parentheses,
From zeros, sevens, A's and Z's,
Constructs, with magic reckonings,
The pointers needed for its trees.
It builds the trees with complex code
With rubout processing bestowed;
When typing errors do forebode
The rubout makes recovery tame,
And losers then will oft exclaim
Their sanity to LISP is owed -
To help these losers is LISP's aim.)

The flow-control of APL
And OS data sets as well
Are best described as tortured hell.
For LISPers everything's a breeze;
They neatly output all their trees
With format-free parentheses
And see their program logic best
By how their lovely parens nest.
While others are by GOs possessed,
And WHILE-DO, CASE, and all the rest,
The LISPing hackers will prefer
With COND their programs to invest
And let their functions all recur
When searching trees in maddened quest.

Expanding records of fixed size
Will quickly programs paralyze.
Though ISAM claims to be so wise
In allocating overflow,
Its data handling is too slow
And finding it takes many tries.
But any fool can plainly see
Inherent flexibility
In data structured as a tree.
When all their efforts have gone sour
To swell fixed records, losers glower.
But list reclaimers hour by hour
By setting all the garbage free
Yield CONSequent capacity:
Thus trees indefinitely flower.
(And trees run on atomic power!)

To men of sensibility
The lesson here is plain to see:
Arrays are used by clods like me,
But only LISP can make a tree.


-- The Great Quux

(with apologies to Joyce Kilmer)


(C) Copyright 1973 Guy L. Steele Jr. All rights reserved.