Heck

From Esolang
Jump to navigation Jump to search
Logo by User:PixelatedStarfish
Heck
Paradigm(s) Imperative
Designed by User:PixelatedStarfish
Appeared in 2021
Memory system Stack-based
Computational class Turing complete
Major implementations Heck Interpreter (Java)
Influenced by Lenguage
Influenced Wheel, Vessel
File extension(s) .heck


Heck is a programing language designed such that source code is expressible as a hexadecimal number. It was created by User:PixelatedStarfish in 2021. The esolang is designed such that the uninitiated will utter "What the heck?!" upon attempting to read source.

The language was initially conceived as similar to Lenguage, such that a hexadecimal value would be converted to binary and evaluated at a low level.

Operations in Heck

Heck is stack based. The following operations can modify the stack.

Caption text
Operation Desc
0 ADD V to val at top of stack
1 SUB V from val at top of stack
2 GOTO L (Label)
3 LABEL L
4 GOTO L if 0
5 GOTO L if Stack Empty
6 Push V
7 Pop
8 Print top val as char
9 Print top val in decimal
A Print top val in hex
B Duplicate top value and push
C Shuffle stack
D Empty stack
E Sum top two values then push
F End Program
<explicit comment> A comment

Syntax and Grammar

Syntax

  • An operation is denoted by a single character ranging in value from 0 to F (0 to 16 in decimal).
  • Some operations take a single two character argument ranging from 00 to FF (00 to 255 in decimal).
  • An operation followed by an argument is called a codon, which cannot exceed three characters.
  • A character that is part of an argument is not interpreted as an operation.
  • Whitespace and non-hex characters are ignored. Comments are explicitly indicted by angle brackets. < >.

Grammar in EBNF

Program ::= {{Op} | {Codon}} 
Codon ::= Op, Arg
Op ::= Val
Arg ::= Val, Val 
Val ::= ‘0’ | ‘1’ | ‘2’ | ‘3’ | ‘4’ |  ‘5’ | ‘6’ | ‘7’ | ‘8’ | ‘9’ | ‘A’ | ‘B’ | ‘C’ | ‘D’ | ‘E’ | ‘F’

Program Examples

For debugging purposes, a parse string is included in the interpreter output such that codons and operations are separated by a slash.

Hello World

6488645864C864C864F86208657864F8652864C86448
Parse:  648/8/645/8/64C/8/64C/8/64F/8/620/8/657/8/64F/8/652/8/64C/8/644/8/

Truth Machine

6003009401200301
Parse: 600/300/9/401/200/301/

Random Number (1 - 10)

60160260360460560660760860960AC9
Parse: 601/602/603/604/605/606/607/608/609/60A/C/9/

Proof of Turing Completeness

This proof of Turing Completeness shows that Heck is translatable to bf to establish Turing Completeness. The unbounded stack of values is comparable to the unbounded tape of a Turing machine. A value on the stack can store an integer, which is more than sufficient to act as a bf cell. For all intents and purposes, the value at the top of the stack is pointed to and can be modified.

To translate between the two languages, use this table. (Note XX and YY stand in for hex values.)

Conversion Table
Heck bf Desc
7 > increment
6XX < decrement
001 + add 1 to cell
101 - take 1 from cell
8 . Output ASCII value at cell
6XX , Take input at (next) cell
4XX [ Jump past ' ] ' (to label X)
4XX 2YY 3YY ] goto ' [ ' (label Y) if cell is greater than 0

External Links