Gaia
A golfing language that takes its stack from CJam and its operators and metas from Jelly.
Turing complete: unknown · ●●○ moderate
Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Gaia's README names its sources, mostly CJam and Jelly with a little of Ohm and SOGL. Programs are a stack language, as in CJam, but written in its own code page full of accented letters and arrows, as in Jelly. Each line of a program is a function, and the last line is the one that runs.
Read the story
Input is implicit. An operator that finds too few values on the stack reads the next line of input, and once the input is spent it reads the last value again. At the end only the top of the stack is printed.
The machine
One stack of big integers, floats, strings and lists. Each operator does something different for each mix of types; × multiplies two numbers, repeats a string, and joins a list with a string.
| Op | Does |
|---|---|
12 3.5 - “text” 'c | Literals; - alone is -1 |
[ ... ] | Gather what was pushed in between into a list |
+ ⁻ × ÷ % | Arithmetic and their string and list forms |
: ; | Duplicate the top; copy the second over it |
… f Σ Π | Range from 0, factorial, sum, product |
p q | Print, without and with a newline |
@ | Read a line of input |
₂ after an operator | Run it twice; any subscript number works |
Example
The third program has only +.
The third program has only +. The stack is empty, so + reads both of its values from the input.
This implementation is a subset. It has the literals and about thirty operators and stops with a reason on blocks, metas, calls between lines and the rest, rather than guess.
Patterns it teaches
- Code golf: implicit input and output cost no bytes at all.
- Stack machines: the stack is the only memory.
Try this
- Print the numbers 0 to 9 as a list.
- Read a word and print it three times.
- Hard: print the sum of the digits of the factorial of 10.
Further
- The reference interpreter, github.com/splcurran/Gaia, in Python 3, with
codepage.md - Related: CJam, Jelly
See also
Also in Golfing
Write your own in Run Convert a program from Gaia
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gaia.
Command line
shib run gaia -e '+' --input '3
4
'shib manual gaiaSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/gaia.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language