From Esolang
Jump to: navigation, search

HARSH is a programming language made up in about ten minutes in a fit of boredom. It has 13 commands, an accumulator, and a stack. It is Turing complete, with a Bitwise Cyclic Tag interpreter on the way

Language Overview

Command Number Command Name Command Name
1 a Increment accumulator
2 d Double the accumulator
3 o Set accumulator to 0
4 p Push accumulator onto stack (doesn't change the accumulator's value)
5 u Pop from stack into the accumulator
6 r Rotate stack, i.e. puts the top stack value onto the bottom
7 h If accumulator is 30, jump ahead a character
8 q Ask the user if the command following should be executed, in the form of a yes or no question. If the user answers yes, run it, otherwise, jump one command
9 b Jump backwards x characters, where x is the value stored in the accumulator. (If the program attempts to jump past the first character, it will simply jump to the first character instead)
10 c Print the accumulator as an ASCII character
11 n Output the accumulator as a number
12 e Exit the program
N/A z See below:

'z' is the most complex command in the language. It takes the accumulator, and executes a command according to what the accumulator's value is. Using the list above, we can see which commands will be executed. 1 will perform a, 2 will double, etc. etc. However there are two exceptions: the z command cannot execute itself, and e will only be run if the accumulator is 12, not 13.

If the accumulator is 0, or greater than twelve, z does nothing.

The stack is dynamically allocated, so it can be any size you want as long as you have enough memory

Comments aren't allowed inside of code, but text will be ignored if placed outside the program, such as after 'e', or after a catch-all 'b'

Interpreter Help

To compile the interpreter with gcc just type:

gcc -o HARSH HARSH.c

type ./HARSH -t or ./HARSH -T to open terminal mode, you should see this:

you@your-computer:~/File/Path$ ./HARSH -t

You can type in any program into the prompt, and after it either fails or finishes, it will give you a second prompt. Type 'exit' (all lowercase) to exit the terminal

type ./HARSH -f (filename) or ./HARSH -F (filename) to open the program (filename).hrs. You should see something like this:

you@your-computer:~/File/Path$ ./HARSH -f hello

Info of note:

The interpreter will, and always should, put a newline after the program exits. This is correct and expected behavior, and all other implementations should do this as well.

The interpreter will ignore tabs and spaces, but not newlines. All other implementations should to the same.


Hello World:


Note: this program is by far not the smallest possible, and revisions may be created. However, this is the first version that worked.

Hello World 2:


Smaller hello world program.



Technically a quine:


(If you type in this program, this error should show)

Turing Completeness

HARSH can be directly transpilled to and from BCT, using this table:

BCT Command HARSH equivalent
0 p
10 puaadaaaddaahohuhr
11 puaadaaaddaahohahuhr

NOTE: These substitutions assume you have pushed the bit string onto the stack. (you can use au and oau to push 0 and 1 values onto the stack. However, this is harder to understand, as values must be pushed backwards relative to their intended orientation (i.e. ou aou auo to push 110) You can fix this by using our and oaur, which allow you to put them "forwards")

External Reasources

Find the Interpreter and some example programs HERE: (Look for the .hrs file extension)