The ETA Project

Designed by Mike Taylor, beginning Tuesday 24th August 1999
Copyright © Mike Taylor, 1999.

This document may be freely redistributed provided it is not modified in any way. Specifically, the authorship must remain clear. All feedback is extremely welcome, and should be emailed to the author at mike@miketaylor.org.uk.

Table of Contents

Introduction

This is the home page of ETA, the programming language that not only resembles natural language, but can resemble whatever specific natural language you want (with the exception of those that require non-Latin characters: apologies to Chinese and Japanese programmers.)

ETA is the language in which:

No heat: "hello.eta", written by Mike Taylor

** FUNGICIDE **
-- Fungus calendar --
CURTSEY:
	Fungal toe!  Fungal toe!  Fungal hoe!
		-- (Burnt programmer nucleus)
	Ooooooo!
CRUDDY 2nd TOE:
	Nine(!) fungal hyaena toe5!
	Dungy alfalfa, penalty superlunary -- Oh, blubber!
	Ooooooo!

... prints the classic message, ``Hello, world!''.

Here you will find everything you need to start programming in ETA: a comprehensive specification for ETA, and for its assembler, EAS; sample ETA and EAS programs; and interpreters that will enable you to run ETA programs and compile EAS programs into ETA.

In time, I hope an ETA user-community will grow up, contributing to the ETA standard library (see below), and writing programs of terrifying elegance and beauty to meet the challenges described in the ETA manual.

Sample Code

Overview

Yes, it would make more sense to describe the ETA language before ploughing in with the code samples; but the shock value would be decreased that way, so here's some code already. (The ETA and EAS manuals are described in the next section, if you absolutely insist on reading things in a logical order.

Sample ETA Programs

The following sample programs are available:

hello.eta The classic ``Hello, world!'' program.
hello2.eta An alternative implementation of ``Hello, world!''.
pip.eta Copy standard input to standard output.
pip2.eta A smaller copy-input-to-output program.
fact.eta Print the recursively-calculated factorial of the number on the standard input stream.
bottles.eta Print the lyrics to ``99 Bottles of Beer on the Wall''.
crlf.eta Test whether the interpreter handles CR/LF sequences correctly.

Sample EAS Programs

The following sample code is available:

Standard Library Functions (see the EAS manual, chapter 5: The Standard Library)
multiply.eas Function to multiply two numbers together by repeatedly adding one of them to an initially-zero accumulator. (Is there a more efficient algorithm?)
writestr.eas Variadic function to print a NUL-terminated string.
writenum.eas Function to print its single argument as a decimal integer.
readnum.eas The converse of printnum.eas: Function yielding the value of a decimal integer written to standard output.

Miscellaneous
true.eas A reimplementation of the Unix utility /bin/true
hello.eas The classic ``Hello, world!'' program.
hello2.eas An alternative implementation of the ``Hello, world!'' program using the standard library WRITESTR function (see above).
pip.eas Copy standard input to standard output.
pip2.eas Compressed version of pip.eas, all on two lines.
reverse.eas Copy input to output, reversed byte-for-byte. (This is done by stacking up all the bytes of the input file, so some implementations will fail for large files.)
fact.eas Program to calculate factorials by defining and (recursively) calling a function, FACT; also uses the standard READNUM, WRITENUM, MULTIPLY and WRITESTR functions.
bottles.eas Print the lyrics to ``99 Bottles of Beer on the Wall'', using the standard WRITENUM and WRITESTR functions.

Documentation

There are two significant documents: the ETA manual describes the ETA language itself, including extensive tutorial examples drawn from the pool of sample code above. In addition, the EAS manual describes EAS, the ETA assembler, which may be used to circumvent some of the more onerous aspects of ETA programming - though the true purist will shun it. Again, example code is included, primarily from the pool above.

The documents should be read in the specified order: ETA first, then EAS.

Interpreters and Other Software

The Reference ETA Interpreter

The Reference ETA Interpreter is a Perl script, available in two forms: the master version and the compressed/obfuscated version. (Improvements to the compression/obfuscation of the latter are welcomed.)

By definition, the behaviour of the reference implementation is always correct. Whenever its behaviour differs from that if another interpreter in a area concerning which the ETA manual is ambiguous, the behaviour of the reference implementation should be emulated. (Any such ambiguities should be emailed to the author at the address above).

EAS, The ETA Assembler

EAS, the ETA assembler is another Perl script.

(By the way, I've only been writing Perl for two and a bit months, so I freely admit that the Perl code in both the ETA interpreter and the EAS assembler is probably pretty non-idiomatic. I bet you can guess I've been writing C for a decade, right? By all means point out my code's unecessary C-o-centricisms to me - I'm keen to improve my Perl.)

EASy, The EAS Interpreter

EAS, the ETA interpreter is a trival shell-script that invokes eas on a named EAS file, then invokes eta on the result. As a by-product, the assembled ETA file is left next to the EAS source.

ETAword

ETAword is a trivial hack to find words from the system dictionary that can be incorporated into an ETA program containing a known sequence of significant characters.

ETAinst

ETAinst is a truly trivial hack to find the significant characters in candidate words for an ETA program. This will tell you (for example) what your name does, so that you can interpolate it in an ETA program.

Download Everything

If you like what you see here, you may find wish to download an entire ETA distribution: a copy of this page, the sample programs, the manuals, both versions of the reference interpreter, the unofficial C version of the interpreter (see below), the assembler, the support utilities, etc.

The On-Line ETA Community

Mailing List

As of 22nd February 2005, there is now an open-membership mailing list for ETA Programmers and implementors, hosted at www.indexdata.dk/mailman/listinfo/eta. Feel free to join!

The Unofficial-But-Fast ETA Interpreter

Harvey Thompson <harveyandsu@yahoo.com> has written an unofficial ETA interpeter in C, which runs about thirty times as fast as the reference implementation.

The Steve ``Haldane'' Sykes Extravaganza!

Steve ``Haldane'' Sykes <haldane1@stephensykes.com> is an old-school hacker with a penchant for quirky languages and (evidently) far too much time on his hands. He has put together his own web-site of ETA material at www.stephensykes.com which contains, among other things, the following highlights:

ETA for the Palm Pilot

Yes! It's true! He's written an ETA interpreter for the Palm Pilot! Not only that, but an ETA-to-C translator, also for the Palm (since the interpreted version takes about two hours to run the ``99 Bottles of Beer on the Wall'' program!)

The software is available at www.stephensykes.com/etapalm.html, together with instructions, screen-shots, and rather a neat ETA program for figuring out whether a given cat is nice or bad. Highly recommended for a visit, even if you don't have a Palm.

ETA for Ruby

Not satisfied with that, Steve's also written an ETA interpreter in the Ruby language. His interpreter, and some commentary, is available at www.stephensykes.com/ruby.html.

The World's Best ETA Program

I don't want to spoil the surprise by telling you what it does, but you really ought to check out a truly awesome program of Steve's, at www.stephensykes.com/tictac.etab

Esperanto ``Hello, world!''

Paul Roberts <sakar@ukonline.co.uk> has written saluton.eta, an Esperanto version of the classic ``Hello, world!'' program - you can see it on the computers page oif his web site. The program text constitues a prose poem for which he's kindly provided the following translation:

Naked fear would cough dryness
Even for nail struggle-pieces
Grandad loves the nail-like bigness
Of the month seed.

Tissue, no, gold, well-- to wave the same.
Bad esperanto!

Naked fear or a cough attacks brightness
No! Curley hair and nine tower-swedes.
Lets take order out of the future. Esperanto!

Now that's what I call programming!

From Russia With Hackery

A Russian hacker who goes by the alias of Mtv Europe <mtve@frox25.i989.net> has pushed the boundaries of ETA further than I'd ever dared dream. There's plenty to see on his ETA page at 212.16.6.108/~mtve/code/eso/eta/, but also at least two other bits that aren't linked from there:

Bilingual ETA Interpreter

He's made an ETA interpreter in obfuscated Perl - just six lines! - which doubles as an ETA program: it's valid in both languages. How cool is that? As an ETA program, it prints *ETA!*; to see this for yourself, download it (as titchyeta.pl, for example), and run:

	perl titchyeta.pl titchyeta.pl

ETA Implemented in Befunge

Maybe surpassing even his previous effort, Mtv Europe's put together a five-line ETA interpreter written in Befunge, one of the most elegant and impenetrable of all esoteric programming languages. And this, too, doubles as a valid (if empty) ETA program. Wow.

Mtv Europe comments (in email):

	Debugging was real fun (very dainty bugs plus first time in my
	life I've rest again 2GB file limit on Win'98 while trying to
	write befunge log of ttt).

Within twenty-four hours of this being published, Steve Sykes commented:

	This is actually great. I tried compiling it to ETA (using my
	bef to eta compiler) with the hello2.eta program installed
	(better than hello because of the transfer to zero exit).  It
	compiled ok, and worked just fine!  So between us we now
	effectively have the first ETA interpreter in ETA.  Very slow
	though - about one char output each 2 secs.

	$ ruby bef.rb <eta_hello.bef >eta_hello.eta
	...
	$ ./sseta eta_hello.eta
	ETA reading source
	ETA lines:10384, compiled len:39491
	Optimisations: Z:15604, ZKs:5219, ZZ:1166, aKst(B):4900
	Ksat(C):2381, Zs:53, Zass(D):2390, aB(E):2482, Zh(U):4121
	KhNeg(F):337, KhPos(G):6385, Ks(M):2622, Uss(W):1491, Kt(L):147
	ETA initilising stack
	ETA running eta code
	Making stack
	Making field
	Hello, world!

	$

To which Mtv Europe replies:

	Rejoicing!  BTW obfuscated perl is also ~3000 times slower
	than sseta (on 'making field' phase, I was nervously waiting
	for 2 days versus 1 minute)

At first I thought he was referring here to an implementation of ``Hello, world!'' that takes two days to run - something I never thought I'd see in my lifetime. Turns out, though, that he was being more ambitious than that, and trying to run Steve's ETA Chess program.

We don't currently have a time estimate for the ``Hello World'' program written in ETA, converted to Befunge, and converted back again; but we do know that it's over TEN THOUSAND LINES LONG. Which is quite an achievement for a ``Hello World'' program.

An ETA Interpreter in Java

Bjorn Bringert <d00bring@dtek.chalmers.se> has written an ETA interpreter in Java, which is available to download as a JAR file. It's linked from his projects page at http://www.dtek.chalmers.se/~d00bring/projects.html. Invoke it like this:

eta/pit$ echo 10 | java -jar /tmp/etaj.jar fact.eta 
3628800
It's fast! Calculating 10 factorial takes about six seconds on my machine (an oldish 500MHz Pentium III running Debian Woody). That's about twice as long as Harv's interpreter written in C, and about 1/50th of the time taken by the reference interpreter.

The JAR contains the source code as well as the compiled classes; you can extract it (into the current directory - beware!) with jar xf etaj.jar

An ETA Interpreter in C++

Eric Schmidt <eric41293@comcast.net> has written an ETA interpreter in C++, which is available to download as a single source file, eta.cpp. Compile it with g++ -Wall -O3 -o eta eta.cpp