Skip to content

Instantly share code, notes, and snippets.

@bolshchikov
Last active April 18, 2022 12:12
Show Gist options
  • Save bolshchikov/faed4bd6b8a8eec6192d1bb7177b8242 to your computer and use it in GitHub Desktop.
Save bolshchikov/faed4bd6b8a8eec6192d1bb7177b8242 to your computer and use it in GitHub Desktop.

Hey there,

Are you familiar with BrainFuck language? No? It's simple. It's a esoteric programming language that consists only of the following chars: +, -, <, >, [, ]

But we are JavaScript fan boys and girls. We want to crete our own.

Creating JS Fuck grammar

We want to create our own awesome esoteric language using only the following valid JS chars: [, ], (, ), ! and + I bet it's enough to write any program that we like.

Task 1: Starting from 0

Rome wasn't built in 1 day, so do we start small. Let's write the expression that evaluates into 0 using only those chars.

Task 2: Adding 1

That wasn't too hard, wasn't it? Now let's add 1 to our alphabet. Write an expression that evaluates into 1.

Task 3: Big numbers

Now we are all set to actually compose numbers. But we will cheat a little - we will treat them as strings. Your task now is to convert an input string that contains numbers into series of JSFuck chars.

For example:

Input: 345 Output: [!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]


Task 4: Alphabet starts with a

Ok, so we have numbers. It's time to start talking... And for that we need letters. Hmm... That's going to be challening. Let's start with a. Your task is to write expression that evaluates into letter a. Tip: remember that string in JS can be treated as arrays.

Task 5: Composing words

Having a simple letter, let's compose a word or may be even an operation. Write an expression that evalutes into alert(0).


Task 6: Writing code

Since we are able to write a command, can't we execute it? Write an expression that evaluates/executed the command alert(0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment