Anders

I have spent the last few years programming with Anders. This has greatly increased my productivity so I’d like to present a brief description of the language and its benefits.

Anders is a 6th generation programming language designed and produced in Stockholm, with further refinements made in Oxford. It is an extremely high level language, with features such as natural language programming, mixed declarative and imperative forms, laziness, and agent-orientation.

Anders programs are text files. The canonical file extension is ‘.anders’ but in practice you can use any extension. They must begin with the following header:

Anders,

After this, you provide a description of what you want the program to do in very high level natural terms. For example, here is a ‘hello world’ program:

Anders,

Could you please write me a Hello World program?

Thanks.

This program demonstrates one of the most unusual features of Anders: the politeness operators. The simplest is the ‘please’ operator which modifies the main statement to make it one unit more polite. There is also the trailing ‘Thanks.’ which serves as both as a gratitude token and a program terminator. More subtle is the question form that embeds the main imperative statement. The ‘Could you ... ?’ structure which takes an imperative statement and makes it more polite at the expense of legibility. It also makes the execution optional which may have adverse effects.

While some people may be familiar with the run-time politeness in INTERCAL, politeness in Anders is a great advance as it is checked at compile-time, by the politeness checker. Impolite programs simply fail to compile. If the politeness deficit is small enough, they will even receive an informative error message.

Anders features a very large vocabulary and very flexible natural language syntax. It even comes with a fully functioning Swedish language module.

The strengths of many languages can be seen in the way they can be used to compute the fibonacci numbers. This typically shows off their use of recursion, but in the case of Anders, it shows both the high level nature of the programming and the need for special modifiers.

Anders,

I know it will bore you to tears, but could you write me a fibonacci numbers program?

Thanks.

In this case, Anders would not compile the program without the use of the presumptive apology: ‘I know it will bore you to tears, but ....’. This is because the program is so trivial as to not be worth Anders’ time.

Another classic program to demonstrate is a Quine, which is a program which outputs its own source code. This is easily done using Anders:

Anders,

Could you please write me a program that simply produces the contents of this file as its output?

Cheers.

(Note the alternative gratitude token here.)

It is surprisingly easy to write an Anders compiler. For example, here is one written in C:

#include <stdlib.h>
int main (int argc, char *argv[])
{
  system("cat %s | mail -s anders anders@aleph.se", argv[1]);
  return (0);
}

Of course it is common to use bootstrapping to produce a compiler written in its own language. Here is a nice example of an Anders compiler written in Anders:

Anders,

Could you write me a compiler for Anders?

Thanks.

The compiler is used at the command line like this:

> Anders fibonacci.anders

The compiled program will be returned to you via email. By default, it compiles into executable files for x86 architectures, but these may not be compatible with your system. You can also request it to compile into other target languages such as C or Matlab or even Anders itself. Here is an example of setting a language:

Anders,

Could you use Matlab to whip me up a simulation of planetary formation, the beginning of life etc. to illustrate the Drake equation and the Fermi paradox? Ideally with some nice animated graphics. Let the user select the relevant constants with sliders, using our current best guesses as defaults. Feel free to put something about power laws in there too.

Thanks!

This is quite a complicated example, but demonstrates a number of nice features of Anders. You can see that specifying the target language is done within the source file itself, rather than as a compiler flag or makefile.

This program features other compile time options too. For example, I used ‘whip me up’ instead of ‘write’ to turn down optimisation for speed and quantity of features, but to turn up the compilation speed — this is very useful for open ended programs. Anders is very good at pattern matching, so the ‘etc.’ pattern completion will work here. The ‘ideally’ operator modifies a statement or clause, making it optional so that Anders can decide whether or not to add that feature based on the current levels of politeness and motivation. ‘Feel free’ is similar, but is typically used to allow Anders to add particularly interesting, but not especially relevant feature, thereby increasing the motivation level. This helps to avoid the dreaded ‘out of motivation’ compile time error. Finally, I decided to simultaneously increase the gratitude level and casualness with a trailing exclamation mark.

While the above is a fairly complex request, the mixture of extreme politeness, the ‘whip me up’ operator, the general excitingness of the project and the use of power laws will combine to produce sufficient motivation for it to compile. Unfortunately the open ended nature of the program may lead to an unstable tradeoff between the time to compile and the fidelity of the simulation. It is quite possible to end up with the compilation taking weeks and then producing an amazingly complex simulation. It is even possible that this unstable tradeoff would make the compilation fail to terminate. An expert user would have added an ‘I really need this by Tuesday lunchtime.’ statement to the end, which would have decreased the politeness, but guaranteed timely termination.

I should also mention that nowdays most operating systems include a built-in IDE for using Anders. This IDE also allows you to email people directly from its main interface.

A word of warning. Anders is the only language I know of to feature compile-time nondeterminism.That is, the results of two compilations of the very same source file might differ. Indeed, it might cause an error (or non-termination) one time, but work fine another time. Luckily, Anders is bound by a promise that termination is guaranteed for compiling each prime numbered program. That is, the 2nd, 3rd, 5th, 7th, 11th… programs sent to Anders will either successfully compile, or will at least return an error message of some sort.

I hope you have begun to see the benefits of switching to Anders and will try writing an Anders compiler of your own.