Copyright © Stephen Sykes, 2001.

This is a utility package for Mike Taylor’s ETA language.

This package is used by a Ruby ETA program, and produces pure ETA code output.

This is written in Ruby - in case you haven’t come across Ruby before, it is an extremely well designed object oriented programming language, which has a number of interesting features. To learn more visit the Ruby home page.

A Ruby ETA program consists of a mixture of the normal operations you would find in any programming language, use of the features of Ruby, and some special functions that are effectively pre defined macros. If you want to build more than trivial ETA programs, then this is probably the quickest way to do it. You can build useful programs without actually having to write a single ETA instruction. And combined with the ETA Beautifier, you will produce nice, readable, executable nonsense.

Classes and methods

There are these useful classes to play with:

  • EtaInt - numbers stored in the stack that you can use for arithmetic and any other purpose
  • InputBlock - a way of sucking an amount of input and storing it in the stack
  • Table - a list of numbers that can be selected from using an index (effectively a read only array)
  • EtaArray - an Array implementation that uses EtaInt - access elements using the [] and []= operators

And there are the following handy methods:

  • eprint - print a list of things from an eta program - numbers and strings
  • input - input a character
  • input_number - input a decimal number
  • eif - if (condition) { }
  • eelse - else { }
  • ewhile - while (condition) { }
  • eexit - exits from ETA by jumping to zero
  • write - write the following ETA to the output, trying to keep track of the stack
  • write_raw - write the following ETA to the output, ignoring the stack
  • next_line - move to the next ETA output line


Writing a Ruby ETA program is simple - you are writing code that will be read by the Ruby interpreter, so you follow the same language conventions as in regular Ruby. A Ruby ETA program will take the following form:

require 'eta.rb'

# program goes here


Some things to note about using etabuilder:

  • EtaInts can be mixed freely with integers in arithmetic operations.
  • The bitwise operations may not work correctly for negative numbers, this will be fixed in a later version.
  • You can use the constants true and false in conditions.
  • The condition logic may not work the way you expect - zero represents true, and all other values represent false. This stems from the way that the transfer instruction works in ETA. In general it is safer to always use a comparison or equality operator.
  • An eelse statement must immediately follow an eif block, like this:
eif (x > y) {
  eprint "x was bigger\n"
eelse {
  eprint "x wasn't bigger\n"
  • Remember that you cannot use && or || - this is due to the way that Ruby works.
  • You can use ! to negate the sense of a condition only at the beginning, where it will be detected:
eif (!(x < y)) {    # legal
eif (x + y != z) {  # legal, x!=y is translated to !(x==y) by the interpreter, & precedence rules apply
eif ((x==y) != z) { # undefined
  • You can define Ruby methods to make life easier:
def pig(z)
  eif (z > 5) {
    eprint "Oink!"


Note that this will result in three instances the comparison and print code in the output - this is not the most object code size efficient method of doing this.

  • It is often useful to use Ruby looping constructs, such as the following:
30.times do |a|
  eprint a, " bottles were on the wall... put another one there...\n"

Again, this is not efficient because the code will be repeated 30 times in the above case.

  • Both InputBlocks and Tables are accessed using the array index operator []. They are read-only constructs.


Just to prove the power of the ETA builder, I wrote this noughts and crosses program.

Source Code

You can download the program here.


Stephen Sykes

Developer, Founder of LibPixel

Back to Overview