WhiteSpace Language Tutorial


Since you have came crawling through the web to this blog, I would guess you might have some basic idea about whitespace.There isn’t many tutorial on this language except this one tutorial but I personally spent about 4 hrs to understand from this link , so I will try to explain it easily. Let me kickstart this blog with briefing you about it.
What is Whitespace?
Whitespace is an esoteric programming language developed by (do you really wanna know?fuck it!). By esoteric I mean, which is understood by a small number of people including me 🙂 .
Whitespace consists of just 3 tokens, this    ,this and this
you might wonder I missed some text but actually I didn’t ! the 3 tokens are a tab, a space, and a line break.Since you won’t be able to see them I will just denote them by T, S, L respectively.
Why Whitespace?
Actually It makes a lot sense to not learn a programming language you can’t see but equally its cool to learn a programming language only you can see! For instance you can  code a virus in whitespace and give it to your friend and they won’t be able to figure out what just happened.
Tutorial
Whitespace makes use of Stacks and Heaps, actually almost every programming language makes use of stacks and heaps for allocating memory during runtime, but in most of them like C++ you don’t have to care about them, you just need to have a basic idea about them but in whitespace you have to actually deal with them.
Every command in whitespace starts with Instruction Modification Parameter(IMP)  , in simple terms if you want to write a command you have to first start it with its IMP and then write the command.LF stands for line break or line feed.
IMPCommand
[Space]Stack Manipulation
[Tab][Space]Arithmetic
[Tab][Tab]Heap access
[LF]Flow Control
[Tab][LF]I/O
IMP tells the computer that either you are going to do some arithmetic operation , or you are going to access heap etc.
Numbers in whitespace are written as a series of tabs and spaces terminated by a line break.Space represents 0 and Tab represents 1.
The sign of a number is given by its first character, [Space] for positive and [Tab] for negative.
For example-



(+)4 can be written as S T    S S L
(-)4 can be written as T    T    S S L
You don’t need to use T,S,L in your code I am just using it for illustration.
So lets come to the first command –

Stack Manipulation (IMP: [Space])

CommandParametersMeaning
[Space]NumberPush the number onto the stack
[LF][Space]Duplicate the top item on the stack
[LF][Tab]Swap the top two items on the stack
[LF][LF]Discard the top item on the stack
So if you want to perform the first operation, the sequence is –
[IMP][command][Parameters(if any!)]
If you want to push (+)4 onto the stack-
[IMP] = S
[Command] = S



[Parameters] = S T    S S L
so final code becomes – S S S T    S S L
If you want to print this number then comes the IMP [tab][LF](look at the first table I wrote on the left of command I/O).
Before printing 4 on screen lets look what I/O can do!

I/O (IMP: [Tab][LF])

CommandParametersMeaning
[Space][Space]Output the character at the top of the stack
[Space][Tab]Output the number at the top of the stack
[Tab][Space]Read a character and place it in the location given by the top of the stack
[Tab][Tab]Read a number and place it in the location given by the top of the stack

So you might see two command for output the first one to output a character and second one to output a number. Since we only pushed 4 onto the stack, the top of the stack contains 4.
so the sequence goes as-
[IMP] – [Tab][LF]
[Command] – [Space][Tab]
[Parameters] – None!
so the code goes as –
T    L
S T
So the whole code becomes-
S S S T S S L
T L
S T 
but wait ! I forgot to mention one thing as soon as finish your code, put a L L L    in the end.
so finally your code becomes-
S S S T S S L
T L
S T L
L
L

here’s the link i have already run it for you – run
If you want to print a string like “Hello World” on screen then just keep pushing the binary of ascii onto the stack and keep outputting it as character.
Now I think I might have cleared some of your doubts regarding  whitespace , I won’t make this tutorial long and end it here.
Thank you . any doubts? just comment here.

Comments