The last TECO user?

That might be me, but more likely I am one of a small group.

What is TECO? In a few words, “a text editor which is also a complete programming language”. There is a fine and entertaining overview in this memoir by Dan Murphy, the original author; you can also take a look at whatWikipedia has to say.

TECO—in fact, my own implementation thereof—is still the text editor I use every day. Here’s how that came about.

Back in the 70’s and 80’s I used TECO in various forms on PDP-10 systems, including a version that I think was called ‘TV’ in which the upper portion (about 18 lines) of a terminal screen displayed a window into the buffer being editing, while the lower portion displayed the current command as typed.

This was the model for my first reimplementation, for the Atari ST, in 68000 assembly language. This was part of a larger program—about 50K bytes in total, as I remember it—that incorporated a 68000 assembler and disassembler, some primitive debugging facilities, a simple command line and a few internally-coded commands (list a directory, for example), and a terminal emulator.

A few years later, when faced with a job where I was using a 8086-type machine, I made a second assembly-language implementation that used a swap file and other mechanisms to hide that architecture’s nasty 64K limit on contiguous arrays.

Finally I was able to move to a third version, written in CWEB, Donald Knuth’s admirable ‘Literate Programming’ dialect of  C. This is what I use today, on both Linux and OS X.

Catering only for myself, I never felt the need to implement all the obscure commands that made their way into TECO. My versions have always been whole-file editors, disregarding the read-a-page / write-a-page cycle that was part of the original. I have always treated the command language as case-sensitive; by making capital letters available in their own right this in turn avoids the need for the two-character ‘Ex’ and ‘Fx’ commands used by ‘classic TECO’.

In further nods toward modern programming practice (and sanity) I never implemented the GOTO command, relying only on loops (and loop exits) and conditionals. Even though TECO’s native command language is basically a kind of bytecode, my versions have always ‘compiled’ the entire command string into a second version for interpretation; this has the advantage that if there is a (detectable) typo it can be caught before any changes to the editing buffer.

Posted in Uncategorized | 1 Comment

Thoughts on rereading The Moon is a Harsh Mistress

There are a number of novels that I have read more than once, and in some cases many times, finding that the world they transport me to is one worth revisiting. Most of these are genre novels, including the work of a number of mystery writers with a highly ‘literate’ style. (This stylistic texture is what largely characterizes the ‘world’ of these books.) I have all the mystery works of Dorothy Sayers, Cyril Hare, and Edmund Crispin, almost everything by Michael Innes and Michael Gilbert, and a good few by Geoffrey Household. Maybe some day I’ll have more to say about these authors or their works.

Then there is the fantasy / science-fiction continuum. In these cases the book takes one to a different ‘world’ in a somewhat stronger sense. Here The Lord of the Rings is the standout: I can’t even estimate how many times I’ve read it, or dipped into it, over the last ~45 years.

I’ve re-read much of Robert Heinlein’s work, but the ones with real staying power are his two masterpieces, Stranger in a Strange Land and The Moon is a Harsh Mistress, the subject of this post.

You should read it, of course. (Some spoilers follow, so read on with discretion if you care about such things.)

One thing that the Wikipedia article doesn’t mention explicitly is the way the use of the Moon as a penal colony follows the precedent of Australia. (I don’t know if it’s still true, but where American English uses ‘transportation’, British usage long preferred ‘transport’, the former word being strongly associated with the meaning ‘exile of convicts to Australia’.)

Since various nations exiled prisoners to the Moon, the colloquial English spoken there is sprinkled with lexical and grammatical elements from, especially, Russian (the words gospodin and tovarishch, the omission of articles). The Australian connection is alluded to by the title of the first of the book’s three parts, “That dinkum thinkum”. All this linguistic flavor contributes to the depth and reality of the alternate world of the novel.

The main action of the novel concerns the revolution that frees Luna from the hegemony of Earth’s Federated Nations. Some economic squeezing has been going on, causing unrest and revolutionary sentiment, but the stakes are raised when the three central human characters come to realize that the ecology of Luna, involving the mining of lunar ice and mineral nutrient deposits to support the growing of grain for shipment to Earth, is radically unsustainable and will result in “food riots six years hence, cannibalism in eight”.

Our situation is not all that different, really. The size of Earth’s current (and projected) population, and the energy-use expectations of the richest one or two billion of us, are also radically unsustainable. But we have no easy targets to revolt against: “We have met the enemy and he is us.”

A notable feature of the novel, and the reason I wrote ‘the three central human characters’ above, is the creation by Heinlein of a fairly well-realized and admirable character who is an AI: Mycroft (‘Mike’) Holmes. The premise, as the narrator, Mannie, states it on page 2 is:

When Mike was installed in Luna, he was pure thinkum—a flexible logic—“High-Optional, Logical, Multi-Evaluating Supervisor, Mark IV, Mod. L”—a HOLMES FOUR. … Human brain has around ten-to-the-tenth [1011, actually] neurons. By third year Mike had beter than one and a half times that number of neuristors.

And woke up.

Indeed, from the use of the expression “woke up”, it is clear that Mike is not only an AI but an artificial consciousness. It also becomes an essential plot point that the ‘owners’ of Mike do not realize that he has achieved sentience: only Mannie understands that Mike is no longer a mere computer, knowledge that he shares only with his two co-conspirators. Mike provides the calculations as to how pressing the ecological crisis is; he then becomes the ‘chairman’ of their revolutionary cell, and invents a second personality ‘Adam Selene’ to play that role by audio and video.

Although this premise is makes for a highly appealing element in the novel, it is, of course, absurd. If AI/AC ever happens, it will most certainly be by design and intention, not inadvertence: the building blocks (‘neuristors’) will likely have an architecture very different from what is most economical in the building of a ‘mere computer’.

Still, as many times as I have read the book, I get sad when Mike ‘dies’ at the end ….

Posted in Uncategorized | Leave a comment

Fun with isograms

Recently I’ve been cultivating an interest in isograms (words with no repeated letter), especially those with seven letters. Another way to count laps at the pool is to run through the alphabet, so that on successive laps I think of seven-letter isograms starting with ‘a’, ‘b’, and so on. A lap (two lengths) is about the right amount of time. I like to take the view that anything acceptable in a general-knowledge crossword puzzle is fair game, so that, e.g., the first-lap choice could be either ‘acronym’ or ‘Antwerp’. Some letters may have to be skipped, or treated differently in that isograms from an explicitly remembered list are acceptable: there are some tasty ones for ‘j’, such as ‘javelin’ , ‘jealous’, ‘Jericho’, and ‘juniper’, but it’s really hard to come up with new ones quickly, and ‘k’, ‘x’, and ‘z’ are pretty much hopeless.

Six-letter words are ridiculously easy, but seven is a nice spot, or one could stipulate ‘at least seven’. Especially when plurals and other non-base forms are avoided (they seem a bit like cheating), seven-letter words are often very ‘tasty’: either they have three syllables (with, obviously, different vowels) or they feature interesting consonant or vowel clusters.

Then the real challenge is to swim 26 laps and be able to remember all the isograms ‘visited’ during the session. Basically, this means rehearsing the list-so-far constantly, although other mnemonic techniques are conceivable. This is difficult brain work! It is perilously easy to come up with ‘insular’, then go back and recite ‘anxious’, ‘Breslau’, ‘crystal’, ‘disrupt’, ‘Ecuador’, ‘foreign’, ‘Germany’, ‘hirsute’, only to find that the ‘i’ word has been completely forgotten.

This linguistic game is actually a revisiting of a spot from my mindscape of decades ago. There is a connection to discrete mathematics, considering words as specified by pattern together with choice of letters, with the pattern of ‘pattern’ being ‘ABCCDEF’, and the isogrammatic pattern ‘ABCDEFG’ being the simplest of all.

Further, there is an even more obscure connection to my days as a PDP-10 assembly language programmer. The PDP-10 had 36-bit words, and the assembler used an arithmetic coding scheme to represent symbols of up to six characters chosen from the set {‘A’, ‘B’, … ‘Z’, ‘0’, ‘1’, … ‘9’, ‘$’, ‘%’, ‘.’} in 32 bits, leaving 4 bits free for flags. The allowable characters were treated as digits with values from 1 to 39, forming a base-40 number. This scheme was known as Radix50, where ‘50’ is forty in octal. (Octal was very much the ‘native language’ of the early DEC machines; an odometer reading of ‘13777.7’ looked like it was about to roll over.)

The point here is that although 32 bits are not enough to represent an arbitrary sequence of seven letters, they are sufficient to represent a seven-letter isogram (showing octal below):

>>> print "%o" % (26*26*26*26*26*26*26)
>>> print "%o" % (26*25*24*23*22*21*20)
Posted in Uncategorized | Leave a comment


If he were courageous and sufficiently capable of thinking outside the box, President Obama should have declared a national emergency and called for an open, ranked-choice election, to be held in a few months, with many open debates in the interim, with advertising forbidden. This, of course, would need to be accompanied by a commitment by Hilary Clinton not to run. If we want to keep the ‘first woman President’ thing alive she could invite Elizabeth Warren to run.

Turnout was about 56%; so Trump’s support amounts to less than 27% of the electorate. And in the special circumstances of this election we would be right to conclude that Trump is completely unacceptable as President to perhaps a clear majority of Americans; this would be even more certain if we consider those who will turn 18 during the next four years.

Posted in Uncategorized | 1 Comment

A small tragedy within the greater tragedy

To continue our commentary on the recent travesty of an election, let us all remember that in the overall scheme of things this is a small tragedy within a greater tragedy.

Human beings, through their reckless expansion and consumption, have guaranteed, at minimum, that people who are young now will live through a long ‘time of troubles’, during which economic migration increases, agriculture becomes more difficult, and coastal cities are under assault by rising sea level—to mention just a few specifics among many. There is, so far, no sign that a critical number of human beings understand what is happening, neither at the grass roots or among our ‘leaders’.

And by the way, the United States, with ~4.5% of the world’s population, is responsible for something in excess of 25% of the already-committed damage to the climate.

So, Trump and the Republicans will try to make policy changes in the wrong direction; but this will happen at the margins. A Clinton administration would not be proposing a large and rising carbon tax, let alone getting it enacted (certainly not with a Republican House). But this is still the single best thing we could do.

Posted in Uncategorized | 1 Comment

The travesty of an election

First, let everyone keep in mind, not just today but for the next four years, that this was not democracy at work; this was our anti-democratic Constitution at work.

The practical effect of the provisions of the Constitution is to give Republicans an unfair advantage in the Presidency (and this has been decisive twice now in the last 16 years), in the Senate (fairly obvious), and in the House of Representatives (this one is harder to explain to people, but true nonetheless).

Every time a talking head interviews a Republican, they should ask them what justification they can give for holding on to this unfair advantage.

If Democrats want to make out like they are the ‘good guys’ in Washington, constantly trolling us all for campaign contributions, they should be proposing Amendments that do away with these anti-democratic provisions. Every Senator or Congressperson, if they pretend to hold lower-case-d democratic values, should support such Amendments. If representatives from small states stonewall them, they are guilty of violating what I would call the ‘implicit oath of office’: to place the public good ahead of personal or partisan considerations.

Indeed, if Republicans stand in the way of this change, they are in the position of abusers: they are saying to Democrats, saying to California and New York and Massachusetts (and so on) ‘An accident of history has given me a position of power over you, but that’s just too bad for you.’ This abuse is less egregious than what went on in South Africa in the days of apartheid, but it is still abuse.

‘That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it …’

Posted in Uncategorized | 1 Comment

An admirable book on consciousness

On a recent long train journey, I read Consciousness: a user’s guide, by Adam Zeman (Yale, 2002), and I cannot recommend it too highly. The author is a neurologist and a teacher of neurologists, with an engaging and lucid prose style. He inclines strongly (as do I) to the belief that physical facts about brains are sufficient to account for consciousness, but without being strident about it; he recognizes that it is very natural for us to feel that there is something mysterious about consciousness.

From his Preface:

I wrote this book partly to satisfy my own curiousity about consciousness, partly because I felt a need for an introduction to the subject which would do justice both to the science and to the philosophy of consciousness, to ‘mechanics’ and to experience. Much of the recent writing about consciousness, some of it brilliant, has been polemical and partial: I have done my best to strike an equitable balance between the warring faction, to chart out the territory and draw a faithful map.

After an initial exploration into the contemporary and historical usage of the word ‘conscious’ and its close relatives, he turns to neurology, providing a detailed but accessible introduction to the structure and activity of neurons and brain structures, with special emphasis on the systems subserving vision. This material can be a bit dry, but the narrative is enlivened by many excursions: into the stages of sleep, into faints, whether induced recreationally or by the large g forces to which fighter pilots are subjected, into ‘opium, alcohol and other anaesthetics’, and especially into those ‘experiments of nature’ where selective damage to the nervous system reveals subtleties that are invisible when everything is working properly: agnosias, neglect, and blindsight, for example.

The book then steps back to look at what evolutionary biology can tell us about neurology and consciousness, and how other mammals stack up compared to humans. The last Part, ‘Consciousness considered’, first surveys a number of grand theories about consciousness coming from the scientific side, and then takes up what historical and contemporary philosophers of mind have to say on the matter.

There is one especially choice passage that I must quote and comment on. In the course of taking up vision there is a subsection headed ‘Recognition’:

Recognition is usually so effortless that we take it for granted. Once in a while a visual mistake startles us from our complacency: a tree trunk on an evening walk looms up like a dark attacker, a twist of black cotton on the floor announces itself as SPIDER. …

A little reflection reveals that such processes are not the exception but the rule. Our knowledge of the world pervades perception: we are always seeking after meaning. … What we see resonates in the memory of what we have seen: new experience always percolates through old, leaving a hint of its flavour as it passes. …

What we see resonates in the memory of what we have seen: this captures, precisely but also poetically, why, in my view, the so-called ‘hard problem of consciousness’ is not a problem at all, even if it will also and forever remain in one sense a mystery. If it is like something to ‘see red’ (in what seems to be the universal canonical example), what it is like is seeing red on thousands of previous occasions.

Posted in Uncategorized | 1 Comment