We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Joke computer programming language

From Esolang
Jump to navigation Jump to search

Joke computer programming language or JCPL is an esolang created by User:None1, it runs on an imaginary joke 1-bit binary computer.

Memory model

It has a tape with 2 bits and a memory pointer initially at the first bit. In the beginning, the program (represented as binary bits) itself is written into the tape from the first bit to the second, bits that are not written stay 0. It can be seen that a program in JCPL has to be at most 2 bits long, so there are only 7 valid programs.

Commands

There are only two commands, represented by the binary bit 0, and 1.

0 Bitwise not current bit
1 Move the pointer to the other bit

For instance, take this program:

01

as an example

Initially, the tape is:

01
^

In the first command 0, the first bit is negated, thus becomes:

11
^

In the second command 1, the pointer moves to the second bit, thus becomes:

11
 ^

Interpreter

Python

c=input()
if len(c)>2:
   raise SyntaxError('Invalid program')
tape=[]
for i in c:
   if i in '01':
       tape.append('01'.index(i))
   else:
       raise SyntaxError('Invalid program')
while len(tape)<2:
    tape.append(0)
p=0
for i in range(len(c)):
    if i:
        p=1-p
    else:
        tape[p]=1-tape[p]