The Story Of Mel

Many (I often wonder if not actually most) so-called, self-professed developers today are nothing of the sort.

Back in my day, your IDE was a text editor (anything from EMACS to Notepad) … and an API (if you even got one) was a document listing the libraries installed with the app, the functions in them, what parameters they took (in what order) and what values (if any) they returned (and their order).

That was it.

“Here’s the API document, here’s your brief, here’s your text editor, have the code ready in two days.”

These days, it seems, everything consists of somebody else’s framework, containing three or more other people’s frameworks, each consisting of yet another three frameworks by yet others, containing someone else’s frameworks … and the scriptkiddies just #include everything, press the [COMPILE] button and voilà, they’ve ‘developed’ something.

See here …

Sit them down in front of a text editor and tell them to write some code of their own and (if they even grasp what’s being asked of them in the first place) I wouldn’t be at all surprised if they burst into tears.

Sure, I get it … why reinvent the wheel?

But the problem is … if you’ve been paying attention at all recently, you’ll be aware that an awful lot of the frameworks and libraries they unthinkingly rely upon are riddled with exploits and even malware (a number of commonly referenced Python libraries have been in the News recently, for instance),

I don’t know … they just don’t make developers the way they used to, it appears.

(I’m sure Anthony Lawrence and I could have a good grumble about the youth of today over a few beers 😉)

Frameworks? Real developers don’t need no stinking frameworks!

In factreal developers don’t even need a text editor!

This was posted to Usenet by its author, Ed Nather (<nather@astro.as.utexas.edu>), on May 21, 1983.

[N.B. during its life, the original got transmogrified into ‘free verse’, which Nather later declared he preferred to his own original prose, but I hate it and have, therefore, reformatted it into prose form, to the best of my ability to discern the logical structure].

A recent article devoted to the macho side of programming made the bald and unvarnished statement:

Real Programmers write in FORTRAN.

Maybe they do now, in this decadent era of Lite beer, hand calculators, and “user-friendly” software but back in the Good Old Days, when the term “software” sounded funny and Real Computers were made out of drums and vacuum tubes, Real Programmers wrote in machine code.

Not FORTRAN. Not RATFOR. Not, even, assembly language.

Machine Code.

Raw, unadorned, inscrutable hexadecimal numbers.

Directly.

Lest a whole new generation of programmers grow up in ignorance of this glorious past, I feel duty-bound to describe, as best I can through the generation gap, how a Real Programmer wrote code.

I’ll call him Mel, because that was his name.

I first met Mel when I went to work for Royal McBee Computer Corp., a now-defunct subsidiary of the typewriter company. The firm manufactured the LGP-30, a small, cheap (by the standards of the day) drum-memory computer,and had just started to manufacture the RPC-4000, a much-improved, bigger, better, faster — drum-memory computer.

Cores cost too much, and weren’t here to stay, anyway.

(That’s why you haven’t heard of the company, or the computer.)

I had been hired to write a FORTRAN compiler for this new marvel and Mel was my guide to its wonders.

Mel didn’t approve of compilers.

“If a program can’t rewrite its own code”, he asked, “what good is it?”

Mel had written, in hexadecimal, the most popular computer program the company owned.

It ran on the LGP-30 and played blackjack with potential customers at computer shows.

Its effect was always dramatic. The LGP-30 booth was packed at every show, and the IBM salesmen stood around alking to each other. Whether or not this actually sold computers was a question we never discussed.

Mel’s job was to re-write the blackjack program for the RPC-4000.

(Port? What does that mean?)

The new computer had a one-plus-one addressing scheme, in which each machine instruction, in addition to the operation code and the address of the needed operand, had a second address that indicated where, on the revolving drum, the next instruction was located.

In modern parlance, every single instruction was followed by a GO TO!

Put that in Pascal’s pipe and smoke it.

Mel loved the RPC-4000 because he could optimize his code: that is, locate instructions on the drum so that just as one finished its job, the next would be just arriving at the “read head” and available for immediate execution.

There was a program to do that job, an “optimizing assembler”, but Mel refused to use it.

“You never know where it’s going to put things”, he explained, “so you’d have to use separate constants”.

It was a long time before I understood that remark.

Since Mel knew the numerical value of every operation code, and assigned his own drum addresses, every instruction he wrote could also be considered a numerical constant.

He could pick up an earlier “add” instruction, say, and multiply by it, if it had the right numeric value.

His code was not easy for someone else to modify.

I compared Mel’s hand-optimized programs with the same code massaged by the optimizing assembler program, and Mel’s always ran faster.

That was because the “top-down” method of program design hadn’t been invented yet, and Mel wouldn’t have used it anyway.

He wrote the innermost parts of his program loops first, so they would get first choice of the optimum address locations on the drum. The optimizing assembler wasn’t smart enough to do it that way.

Mel never wrote time-delay loops, either, even when the balky Flexowriter required a delay between output characters to work right.

He just located instructions on the drum so each successive one was just past the read head when it was needed; the drum had to execute another complete revolution to find the next instruction.

He coined an unforgettable term for this procedure.

Although “optimum” is an absolute term, like “unique”, it became common verbal practice to make it relative: “not quite optimum” or “less optimum” or “not very optimum”.

Mel called the maximum time-delay locations the “most pessimum”.

After he finished the blackjack program and got it to run (“Even the initializer is optimized”, he said proudly), he got a Change Request from the sales department.

The program used an elegant (optimized) random number generator to shuffle the “cards” and deal from the “deck”, and some of the salesmen felt it was too fair, since sometimes the customers lost.

They wanted Mel to modify the program so, at the setting of a sense switch on the console, they could change the odds and let the customer win.

Mel balked.

He felt this was patently dishonest, which it was, and that it impinged on his personal integrity as a programmer, which it did, so he refused to do it.

The Head Salesman talked to Mel, as did the Big Boss and, at the boss’s urging, a few Fellow Programmers.

Mel finally gave in and wrote the code, but he got the test backwards, and, when the sense switch was turned on, the program would cheat, winning every time.

Mel was delighted with this, claiming his subconscious was uncontrollably ethical, and adamantly refused to fix it.

After Mel had left the company for greener pa$ture$, the Big Boss asked me to look at the code and see if I could find the test and reverse it.

Somewhat reluctantly, I agreed to look.

Tracking Mel’s code was a real adventure.

I have often felt that programming is an art form, whose real value can only be appreciated by another versed in the same arcane art; there are lovely gems and brilliant coups hidden from human view and admiration, sometimes forever, by the very nature of the process.

You can learn a lot about an individual just by reading through his code, even in hexadecimal.

Mel was, I think, an unsung genius.

Perhaps my greatest shock came when I found an innocent loop that had no test in it. No test. None.

Common sense said it had to be a closed loop, where the program would circle, forever, endlessly.

Program control passed right through it, however, and safely out the other side.

It took me two weeks to figure it out.

The RPC-4000 computer had a really modern facility called an index register. It allowed the programmer to write a program loop that used an indexed instruction inside; each time through, the number in the index register was added to the address of that instruction, so it would refer to the next datum in a series.

He had only to increment the index register each time through.

Mel never used it.

Instead, he would pull the instruction into a machine register, add one to its address, and store it back.

He would then execute the modified instruction right from the register.

The loop was written so this additional execution time was taken into account — just as this instruction finished, the next one was right under the drum’s read head, ready to go.

But the loop had no test in it.

The vital clue came when I noticed the index register bit, the bit that lay between the address and the operation code in the instruction word, was turned on — yet Mel never used the index register, leaving it zero all the time.

When the light went on it nearly blinded me.

He had located the data he was working on near the top of memory — the largest locations the instructions could address — so, after the last datum was handled, incrementing the instruction address
would make it overflow.

The carry would add one to the operation code, changing it to the next one in the instruction set: a jump instruction.

Sure enough, the next program instruction was in address location zero, and the program went happily on its way.

I haven’t kept in touch with Mel, so I don’t know if he ever gave in to the flood of change that has washed over programming techniques since those long-gone days.

I like to think he didn’t.

In any event, I was impressed enough that I quit looking for the offending test, telling the Big Boss I couldn’t find it.

He didn’t seem surprised.

When I left the company, the blackjack program would still cheat if you turned on the right sense switch, and I think that’s how it should be.

I didn’t feel comfortable hacking up the code of a Real Programmer.

[1999 update: Mel’s last name is now known. The manual for the LGP-30 refers to “Mel Kaye of Royal McBee who did the bulk of the programming […] of the ACT 1 system”.]

[2002: A copy of the programming manual for the LGP-30 lives at http://ed-thelen.org/comp-hist/lgp-30-man.html]

Let’s look at that in more detail, shall we?

I have often felt that programming is an art form

And here’s the evidence for it …

He could pick up an earlier “add” instruction, say, and multiply by it, if it had the right numeric value.

[…]

He just located instructions on the drum so each successive one was just past the read head when it was needed; the drum had to execute another complete revolution to find the next instruction.

[…]

Instead, he would pull the instruction into a machine register, add one to its address, and store it back.
He would then execute the modified instruction right from the register.

That’s just beautiful in it’s simple pragmatism and pragmatic simplicity — and that, right there, … the inextricable combination of the two … is OOP in its purest essence (never mind the implementation, the conception alone is the essence of it).

As for this

The carry would add one to the operation code, changing it to the next one in the instruction set: a jump instruction.

The last time I laughed out loud in delight at a concept like that, it was when I first learned of the Redcode Imp in Core War.

The explanation of the Imp in the article is a trifle unprepossessing.

The actual code is simply: MOV.I $ 0, $ 1

MOV.I copies an entire instruction from A to B. A is $ 0 and points directly to the imp in the current location. B is $ 1 and points directly to the next location.

When the imp executes it copies itself from the current location to the next location. When the next location is executed, it contains an exact copy of the imp and so the process repeats. — https://programminggames.org/Core_War

That … right there … is the essence of both OOP and recursion … a single, self-contained operator that is its own operand … a code singularity … the ultimate program — if there is a code God, the Imp is ‘Him’’ … the alpha and the omega, needing no more than itself to represent everything that programming is (namely, Dear computer: your next instruction is to execute the next instruction).

It’s perfectly recursive and achieved with a single instruction — a thing of sublime beauty in its simplicity.

And to backtrack a moment …

Since Mel knew the numerical value of every operation code, and assigned his own drum addresses, every instruction he wrote could also be considered a numerical constant.

He could pick up an earlier “add” instruction, say, and multiply by it, if it had the right numeric value

Many years ago, I stumbled upon a language called NNAPL (Neural Net Application Programming Language) by its developer.

It was a strange thing.

At the time (around 1993), its function was astounding to me — I just couldn’t figure out how it was possible.

You gave it some training data and it built a neural net from it.

Wait, what?

I’d programmed neural nets from scratch myself … writing the code to tell the computer how many nodes to put in the input layer, how many in the hidden layer, how many in the output layer … how to read the training data, what the goal was, how to compare the result to the goal and backprop (or whichever function I wanted) the error correction.

I knew how they worked intimately.

But NNAPL … you just issued the command trainnet <training data file> … and it built an appropriate net from it without any instruction, creating the input layer, hidden layers, output layer, goal and correction method without any input from you.

I’m not even sure how possible it would be to do that today, never mind how it was achieved back then.

It did more than that though: quite apart from the seeming miracle of a single command to have a neural net build itself from … well, nothing … it was actually a fully fledged language in its own right that could be used to write any program you wished, just like any other language, such as C, PASCAL or whatever.

The thing was though … it only had one inbuilt datatype: INT.

Everything else you wanted to do with it entailed defining a datastructure in terms of its length in bytes (not forgetting to add two for a CR/LF marker as the delimiter of a variable). Beyond INT, here was absolutely no typing … and, thus, nothing to prevent you from adding 144 to Thursday and dividing the result by the cosine of Mrs Miggins’ cat.

The potential of a language like that was fascinating — what could be done with it that might transcend the limitations of previous paradigms … what unexpected functions might be developed that would facilitate the manipulation of not merely data but conceptual structures in ways hitherto never even imagined, let alone possible? (This was potentially way past self-rewriting functions in LISP).

I played with it for a while, but got bogged down trying to teach it floating point arithmetic from first principles (which turned out to be a lot harder to implement than I anticipated)

… and I had other, more pressing matters to attend to ¹, so I never did find out how high a cat could be made to jump when poked with the integral of six lemon-flavoured triangles passing under the neighbours’ washing-line every purple week of June for the last six years.

But it too was a thing of fascinating simplicity and ethereal beauty in its way.

I can find no record of it today and I’m not sure if I have a copy of the compiler/interpreter on any of my old disks any more — I’d be delighted to find I did though ².

Aaaaaanyhow … Mel … the master of programming by side-effect ³ … the programmer’s programmer, breaking the rules and abusing the facilities, refusing to conform or be restricted by convention — test for boundary conditions? He don’t need no stinking test … he recognises no boundaries (JMP++)!


¹ Neural nets to build, genetic algorithms to keep an eye on, first year students to lightly torture in the name of obtaining response time data that might be used to determine differential perception vectors in 3D colour-space (which latter is a lot more interesting than it might sound actually).

² I never did like the cat.

³ There was a very useful one in 4DOS v4.02.

An unintended side-effect of issuing one of its internal commands was that it loaded one of the registers with the name of the directory in which the previous command had been issued. In those days, any program you ran at the command prompt might drop you out in a completely different location, depending on what it did during its execution and, if you weren’t expecting it, it could be the cause of much confusion, if not despair ⁴.

One of the many things that 4DOS could do that command.com couldn’t was execute inline commands in the prompt.

So, I’d execute that internal command inside the prompt, ignore the result (in which I had zero interest), grab the side-effect from the register and print the value to the prompt, followed by $command itself. So, I always knew where I had been when I issued the previous command and what it had been, even if I were now in a completely different directory and the evidence of the command had been erased from History — which was nice.

I also had a lot of fun replacing people’s command.com with a renamed version of 4DOS.com that I modified to behave like Weizenbaum’s ELIZA, (Rogerian non-directional) therapist simulation .

It worked just fine for most things … behaved perfectly normally.

But, if you tried to delete files, it didn’t just stop at “Are you sure?” If you said “Yes”, it replied with “Are you REALLY sure?” If you replied with “Yes” again, it responded with “Tell me more about your files” and led you on a merry dance for a while before it finally agreed to delete it/them.

You can’t do that any more — *sigh* computers aren’t as much fun as they used to be.

⁴ Such a lot of files
They must have been important —
but now they are gone.

https://en.m.wikipedia.org/wiki/ELIZA

There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live and too rare to die.