From Esolang
Jump to navigation Jump to search
Paradigm(s) Imperative paradigm
Designed by User:Emerald
Appeared in 2020
Memory system Cell-based
Dimensions Two dimensional
Computational class Unknown computational class
Major implementations Python interpreter by User:Bangyen
Influenced by Fish, Befunge
File extension(s) .dig, .dg

Dig is a language made by User:Emerald using a 2d grid, with a 3rd direction for the language’s namesake, Dig. It is inspired by Befunge-93 and ><>, but is no way related to DigFill, a similarly sounding language.


There are 2 types of commands in Dig, Movement and Work. The main difference is that Work only can be executed underground, accessible by the dig command; meanwhile, movement is restricted overground.


Command What it does
^ Points Mole up
> Points Mole right
' Points Mole down
< Points Mole left
# Rotates Mole to left when value beside it is 0, and right when 1. When it’s neither of those, keep straight.
$ Mole “digs” to the 3rd dimension, keeping its direction until it has moved the amount of tiles beside the $
@ Halt


Alpha-numericals and .,!? When Mole passes over, memory is overwritten with value
% Overrides current value with space when 0, and newline when 1
= Overrides current value with a single character from user
~ Overrides current value with a single integer from user
: Outputs Value in memory then, replaces it with 0
+ Overrides current value with itself plus the number besides the +
- Overrides current value with itself minus the number besides the -
* Overrides current value with itself times the number besides the *
/ Overrides current value with itself divided by the number besides the /
; When Mole passes over, the “;” is given the Moles current value

Interpreters when faced with more than one value next to “#”, “$”, or “%” should prefer use up, right, down, left.

The mole is the pointer in the program, and starts from the top-left. It needs an arrow to guide its initial direction.

Memory storage

The Mole starts with a value of 0, but can be overwritten with 0-9 | a-Z


There are 3 types of errors in Dig:

Normal Errors

Error: Division by 0


Error: Invalid Character

The character under the mole is not a command.

Error: Out of bounds

The mole is outside the range of the code (Top-left character to Bottom-right).

Interpreter Errors

These errors are specific to interpreters, so they may be different from one to another.

Interpreter Error: Tile memory full

Dig.py uses a list named tmem to store values stored in “;”, the error happens when all values are full.

User Errors

These errors are caused by user intervention in the program.

User Error: Manually halted

The user stops the program pre-maturely.


Hello World

 8        8  0     8

Cat (Never stops)

^2  <

Truth Machine

'   @
 2  >$+:'
    ^21 <


A NAND gate by User:Bangyen.

'2  > $~ >$ 1:@
>$~;#@2   3
    > $~;#@2
         > $0:@

Boolean Function Conversion

A Python program by User:Bangyen to implement a given boolean function in Dig.

from inspect import signature

def convert(func):
    num = len(signature(func).parameters)
    total = 2 ** (num + 1) - 1
    lines = ['' for _ in range(total)]
    pos = [total // 2]

    for j in range(num + 1):
        if j < num:
            for k in range(total):
                if k in pos:
                    lines[k] += '>2$~;#@'
                    lines[k] += ' ' * 7
            pos = [i + 2 ** (num - j - 1) for i in pos] + \
                  [i - 2 ** (num - j - 1) for i in pos]
            for k in pos:
                lines[k] = lines[k][:-2] + '> '

            for k in range(2 ** num):
                arg_list = [0] * num + [int(i) for i in bin(k)[2:]]
                lines[k * 2] += f'>$3{func(*arg_list[-num:])}:@'

    lines[0] = '\'' + lines[0][1:]
    return '\n'.join(k for k in lines).replace('> >', '>  ')

For example, convert(xor) produces the code

'           >  $30:@
     >  2$~;#@
            >  $31:@
            >  $31:@
     >  2$~;#@
            >  $30:@


A Python interpreter by User:Bangyen.

A Lua interpreter by User:DeybisMelendez.