Friday, December 02, 2011

Put Frog on Altar

While reading this Programmers question I realised that the analogy between programming and spellcasting may be more useful than I had considered it to be previously.  One of the points that I've seen mentioned in regards to what makes programming hard is that programming languages don't have any kind of innate meaning.  Over the years, attempts have been made to make programs look more like written English (and I would say Python has come fairly close), but perhaps the trick to having people understand this absence of meaning is the opposite -- making a  language fairly close to English, but with instructions that make as little sense as possible?

It is quite clear that such a language would not be particularly pleasant to write in.  It may also not do much good in terms of teaching what functions should be called, or even what a `function' or `variable' is.  In fact, I wouldn't be surprised if people who start with this language would be intellectually scarred and would have trouble learning any normal language, but maybe having to figure out what ``set fire to the sawdust'' does, and then being able to use that knowledge to achieve something else, would be a fun/enlightening experience.

Now, as for the language.  First of all, I should note that I'm imagining this as something graphical.  Where a normal language would have an interpreter, this would have a wizard who can walk around and interact with the world.  I would prefer for this to not even be textual -- obviously, the wizard would keep a log of what he did (allowing one to discover the commands performed).

The non-interactive version would be in the form of a letter.  The programmer, a wizard himself, is writing to his wizard-friend.  When executing, the program would show this wizard friend attempt to follow the instructions.  (I have not yet decided whether the wizard friend would be trusting enough to follow instructions like ``set self on fire'').  Eventually, the wizard-friend writes a letter back, telling about what happened, and about any mistakes he may have found.

From this description follows a good deal of the structure of the language:  it is imperative, programs (or, more precisely, int main()) are letters, functions are notes, and libraries are books.

Variables are a little harder, but are also fairly clear:  the Wizard has a workdesk, and should be able to split it up into areas, probably recursively.  Each local variable is represented by an object that can accumulate a certain type of value.  For example, an abacus could keep track of numbers, and parchment could have strings written on it.  A mixing bowl could have sulphur and hydrochloric acid added to it and then mixed, and would store the result of that.  A number of primitive operations can be done just with these, such as addition, multiplication, and some string manipulation.

The problem is that while unexpected semantics would be nice, them being unexpected also makes them hard to come up with.  A few things would certainly need to be present:  Estidout, a god who prints all prayers addressed to him onto the night sky;  Estidin, a god who tends to whisper messages from other words into the ears of those who listen for them; Cemathus, a god who is willing to assist in certain calculations; and Segfoltus, a malevolent deity who does not appreciate being called upon.

Perhaps an ad-hoc creation of this `standard library', if it can be called, would be beneficial, as it would make things all the more chaotic.  However, I have yet to think about the details.  It certainly sounds like the kind of thing I should keep in mind, in any case.

Oh, by the way, seeing as English is rather hard to parse, I think this would be interesting to do in Lojban.  That will make it less intuitive, but I think it would show a great use of the language.

No comments:

Post a Comment