Dathanna
Dathanna (Irish for "colors") is an esoteric programming language for Apple II emulators.
Rationale
Most classic computers from the 1980s have emulators so old code can run on modern hardware. Many of these emulators support running as quickly as possible, often several orders of magnitude faster than the original machine. Dathanna takes advantage of this speed to make tolerable an implementation that would otherwise be far too slow on the original hardware.
Dathanna is featured in Chapter 16 of the book Strange Code: Esoteric Languages That Make Programming Fun Again (No Starch Press, 2022).
Language Description
Dathanna programs are constructed from pairs of colored blocks stacked one on top of the other. The top color specifies the command and the bottom a modifier for that command. Programs are arranged on the screen and execute from left to right, top to bottom.
Arithmetic operations use a stack with colors doing double-duty as commands or numbers. The stack supports floating-point numbers but only the integers 0 through 15 can be pushed on the stack directly.
Commands
Commands are a top color with the lower color a modifier.
Value | Color | Top | Bottom |
---|---|---|---|
0 |
black | HALT |
Terminate program (any) |
1 |
magenta | PUSH | push number to top-of-stack (TOS) (any) |
2 |
dark blue | INPUT | number to TOS (orange) |
character to TOS (light green) | |||
3 |
purple | COMPARE | < (gray 1)
|
<= (medium blue)
| |||
> (light blue)
| |||
>= (brown)
| |||
= (orange)
| |||
<> (gray 2)
| |||
(r c -- ) branch (purple)
| |||
(r c f -- ) if (aquamarine)
| |||
4 |
gray 1 | STACK | dup (magenta)
|
drop (dark blue)
| |||
swap (purple)
| |||
rot (gray 1)
| |||
over (medium blue)
| |||
nip (light blue)
| |||
7 |
light blue | TOS as number (orange) | |
TOS as character (light green) | |||
9 |
orange | MATH | + (black)
|
- (magenta)
| |||
* (dark blue)
| |||
/ (purple)
| |||
ˆ (dark green)
| |||
sqrt (gray 1)
| |||
sin (medium blue)
| |||
cos (light blue)
| |||
tan (brown)
| |||
abs (orange)
| |||
exp (gray 2)
| |||
log (pink)
| |||
int (light green)
| |||
rnd (yellow)
| |||
atn (aquamarine)
| |||
mod (white)
| |||
12 |
light green | STORE | ( v idx -- ) (any)
|
13 |
yellow | FETCH | ( idx -- v) (any)
|
14 |
aquamarine | PUTV | TOS to var number (any) |
15 |
white | GETV | var number to TOS (any) |
Examples
Hello, world!
Random Pi
Gnome Sort
Computational class
Like Befunge-93, Dathanna programs are restricted to one screen. Therefore, Dathanna is not Turing complete.