Sacred is a joke esoteric programming language that uses only brackets and spaces.
For example, the below writes Hello World!
to the screen:
())( () () () () () () () () ( )) () () () () ( )) () () )) () () () )) () ()
() )) () (( (( (( (( )( ) )) () )) () )) )( )) )) () ( (( ) (( )( ) )) )) (((
)) )( )( )( ((( () () () () () () () ((( ((( () () () ((( )) )) ((( (( )( (((
(( ((( () () () ((( )( )( )( )( )( )( ((( )( )( )( )( )( )( )( )( ((( )) )) ()
((( )) () () (((
It was specified by Conor O'Brien in 2015 but until today had no interpreter or compiler.
The way it works is very similar to the more famous Brainfuck language, but has some additional commands.
Command | Meaning | Brainfuck equivalent |
---|---|---|
())( |
Indicates Sacred mode 1 (interpret as programming language). | NONE |
()() |
Indicates Sacred mode 2 (ASCII encoding/obfuscation of any text e.g. Sacred Scheme). Mode 2 is not implemented in this interpreter but a short JavaScript snippet can be found on Esolangs for this conversion. | NONE |
() |
Increments the current byte. | + |
)( |
Decrements the current byte. | - |
(( |
Go left in the data strip. | < |
)) |
Go right in the data strip. | > |
( |
Jump past the matching ) if the byte is zero. |
[ |
) |
Jump back to the matching ( if the byte is non-zero. |
] |
((( |
Outputs the current byte as an ASCII character. | . |
))) |
Takes a single-character input as an ASCII character. | , |
((() |
Takes a numeric input. | NONE |
())) |
Outputs the byte as a number. | NONE |
((())) |
Converts the data strip into characters and evaluates them as if they were code. | NONE |
((()())) |
Converts the data strip into characters and evaluates them as if they were code. Places this command at the end of the program to evaluate again the strip ad infinitum. | NONE |
A cat program writes its input directly to its output. This will keep taking integers as input until the user enters 0.
())( ; this is a Sacred program - mode 1
() ; set [0] to 1
)) () () () () () () () () () () ; set [1] to 10 - newline
(( ; return to [0]
( ; loop until [0] is 0
((() ())) ; take integer input and output it
)) ((( ; move to [1] to output newline
(( ; return to [0] to take next integer
) ; end loop
Output:
PS D:\code\sacred> .\sacred examples/cat_int.sacred
1
1
-5
-5
1000
1000
0
0
The following (rather inelegant) program:
())( )) () () () () () () () () () () ( )) () () () () )) () () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ))
() () () () )) () () () () )) () () () )) () () () () )) () () () () )) () () () ()
)) () () () )) () () () () )) () () () () )) () () () )) () () () () )) () () () ()
)) () () () () )) () () () )) () () () () )) () () () () )) () () () )) () () () ()
)) () () () () )) () () () () )) (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( (( ((
(( (( (( (( (( (( (( )( ) )) )) () )) () )) )) () () )) () )) () )) () () )) )) ()
)) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () ))
)) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) ()
() )) )) () () )) () )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () ))
() () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) () )) () )) () () ))
)) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) ()
() )) )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) () ))
() )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () ()
)) () )) () )) () () )) )) )) () () )) )) )) () () )) )) )) () () )) )) )) () () ))
() )) )) () () )) () )) () () )) () )) () )) () () )) () )) )) () () )) () )) )) ()
() )) () )) () )) () () )) )) () )) () () )) )) () )) () () )) )) () )) () () )) ))
() )) () () )) () )) () )) () () )) )) () )) () () )) () )) () )) () () )) )) )) ()
() )) )) )) () () )) )) )) () () )) )) )) () () )) () )) () )) () () )) )) )) )) ()
() )) () )) () )) () () )) )) )) )) () () )) () )) () )) () () ((()))
Writes the following program (sans newlines) to memory and then executes it:
())( )) () () () () () () () () () ()
(
)) () () () () () () )) () () () () () () () () () )) () () () () )) (( (( (( (( )(
)
)) )( )( )) () () () () )) () )) (( (( (( (( )) ((( )) ((( )) (((
This in turn writes :^)
to the screen:
PS D:\code\sacred> .\sacred examples/selfcodesmiley.sacred
:^)
If you replace ((()))
at the end of the program with ((()()))
it will then try to interpret :^)
as a Sacred program and error out because it sees the bracket as closing an unopened loop:
PS D:\code\sacred> .\sacred examples/selfcodesmiley.sacred
:^)Error: Unopened or unclosed loop detected. Commands:
) ((()()))
- Commands are not just delimited by space, but also by tabs and newlines (
\n
and\t
) - The memory starts as a single cell with value 0
- Nested loop capable!
- Negative values allowed - memory blocks are signed integers (
signed int
) - Infinite number of memory blocks allowed
- Enforces against negative pointer locations - must be 0 or above
- Commands
((()))
and((()()))
cause the memory to be evaluated as a Sacred program with its own memory strip initialised with a single cell with value 0 - In keeping with Brainfuck, numbers in memory are integers only -
((()
will only accept an integer
- Conor O'Brien - Esolangs
- Ascii Table