/hugo

Hugo is a programming language created for PLT Games December 2012 Turing Tarpit Competition

Primary LanguagePythonMIT LicenseMIT

Hugo

Overview

Hugo Uses Gotos Only!

Hugo is The Language of the Future!

Hugo is for programmers who feel too constrained by the implicit sequencing of more pedestrian programming languages!

Hugo is designed and developed by your friends at LAMBDA HEAVY INDUSTRIES©™

A Short Example

The shortest non-terminating Hugo program is:

0

Our trained research scientists at LAMBDA HEAVY INDUSTRIES©™ call this Looping Nullary Zero Combinator Prime.1

Syntax

A Hugo program is a set of statements.

  1. A statement begins with a decimal integer. This is the statement's label. Lines that do not begin with a decimal integer are comments.
  2. A statement is an expression in reverse Polish notation. The label is a part of the expression.
  3. A statement evaluates to the label of the next statement to execute. If no such statement exists, execution halts.

With that knowledge in hand, we can better explain how Looping Nullary Zero Combinator Prime works:

Start at label 0, evalute 0 (to 0), and jump to 0.
0

A slightly more interesting program echos input to the screen until EOF is reached:

Read a value into memory cell 0
0 1 , 0 $ +

Compare value to -1
1 1 0 & 0 1 - = + +

If value is not -1, print it and jump to beginning
2 2 0 & . -

Otherwise, halt
3 1 +

This program is called echo.2

Since every statement is both a label and a goto, the statements comprising echo can be put in any order.

Compare value to -1
1 1 0 & 0 1 - = + +

Otherwise, halt
3 1 +

If value is not -1, print it and jump to beginning
2 2 0 & . -

Read a value into memory cell 0
0 1 , 0 $ +

At LAMBDA HEAVY INDUSTRIES©™, we have found this to be a huge win for programmer productivity satisfaction job retention.

Reverse Polish Notation Operators

As echo hinted above, the following RPN operators are supported:

Name Syntax Effect
literal X push(X)
save X Y $ Y = pop(); X = pop(); mem[Y] = X;
load X & push(mem[pop()])
read , push(getchar())
write X . putchar(pop())
add X Y + Y = pop(); X = pop(); push(X + Y)
sub X Y - Y = pop(); X = pop(); push(X - Y)
eql X Y = Y = pop(); X = pop(); push(X == Y)

Execution Details

The Hugo execution model may use any appropriate word size3 but should have at least 1048576 memory cells.4

When read encounters EOF, the value pushed to the stack should be -1.

Hugo can be interpreted or compiled, but should not be orally consumed in any significant quantity.5

Completeness

According to our trained research scientists, Hugo is Turing Complete. Included in the reference implementation is a Hugo program bf.hugo which implements an interpreter for a programming language with an extremely rude name6. Since the rudely-named language has been proven Turing Complete, and Hugo can implement it, we can say that Hugo is Turing Complete.7

Reference Implementation

Here at LAMBDA HEAVY INDUSTRIES©™, our trained research scientists are so committed to theoretical purity, that they have elected not to implement Hugo. We have therefore contracted with a local programmer to produce a reference implementation. The Reference Implementation (hereafter referred to as "The Reference Implementation") includes an interpreter and a compiler that can generate C or LLVM IR8.

The following commands show how to run bf.hugo:

# Via interpretation
$ python hugo.py run examples/bf.hugo < examples/hello.bf
Hello World!

# Via compilation to C
$ python hugo.py gen-c examples/bf.hugo
$ ./bf < examples/hello.bf
Hello World!

# Via compilation to LLVM
$ python hugo.py gen-llvm examples/bf.hugo
$ ./bf < examples/hello.bf
Hello World!

For more information, run:

$ python hugo.py --help
$ python hugo.py run --help
$ python hugo.py gen-c --help
$ python hugo.py gen-llvm --help

Final Remarks

LAMBDA HEAVY INDUSTRIES©™ is copyright and trademark of LAMBDA HEAVY INDUSTRIES©™.

Hugo and The Reference Implementation were created by Chris Parks for the PLT Games Turing Tarpit Competition of December 2012.9

This document and all associated code is released under the MIT license.


1. Patents pending, all rights reserved.

2. echo was named by a different, less excitable group of trained research scientists.

3. 37 bits, for example, would be inappropriate. Negative sizes would be inappropriate, offensive, and impractical.

4. For reasons why, see Guyton and Hall Textbook of Medical Physiology, 12th edition. The short answer is "performance".

5. See footnote 4.

6. Our trained research scientists were positively aghast.

7. Proof by sufficiently complicated example.

8. We're as surprised as you are.

9. Not that that's any kind of excuse.