Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Weird Programming Languages
More than a thousand programming languages have been invented and only about one hundred of them are commonly used. Among these, there are some weird ones, so labeled because of their syntax and the way it represents its code. In this article, we will look into some of these languages and syntax.
Legit
Have you ever landed on a Github project that prints âhello worldâ program, but without any visible code or any content. Check this link https://github.com/blinry/legit-hello and you will see nothing in this repository. But trust me, there is hidden code in this project.
If you see the commit section, you can reveal the magic. Itâs storing the âhello worldâ code inside git commit history. If you clone this project and run the following command, then you can see the hidden code in this project.
git log --graph --oneline
Here are the supported instructions.
- â[<tag>]â: jump to the specified Git tag. For example, [loop] will jump to the tag loop.
- âquitâ: stop the program.
- âgetâ: read a char from standard input and place its ASCII value on the stack. On EOF, push a 0.
- âput:â pop top stack value and write it to standard output as a char. The value is always truncated to an unsigned byte.
- â<Number>â: push the specified integer on the stack. For example, 42 will push the value 42.
- â<Letters>â: unescape string, then push the individual ASCII characters on the stack. For example, âHi\nâ will push the numbers 72, 105, and 10.
- âdupâ: duplicate top stack value
- âpopâ: pop top stack value and discard it
- âaddâ: pop two topmost stack values, add them, push result on the stack
- âsubâ: pop two topmost stack values, subtract top one from bottom one, push result on the stack
- âcmpâ: pop two topmost stack values, pushes 1 if bottommost one is larger, 0 otherwise
- âreadâ: place value of current tape cell on the stack
- âwriteâ: pop top stack value and write it to the current tape cell
- âleftâ: pop top stack value, move tape head left for that many places
- ârightâ: pop top stack value, move tape head right for that many places
Legit programming language source code hosted in Github and you can try out yourself. Read out more about Legit.
Folder
Hereâs another one which does not maintain any code inside its repository. This language keeps its code as folders. Instructions are read according to the order of the folders. Inside these folders, there are three folders to represent Type, Command, and Expression. The number of folders in inside these folders represent relevant mapping with type, command or expression.
Read full description of this language in here
Befunge
This is another interesting programming language which represents its code in two-dimensional space. Take a look following code of infinite loop.
>v^<
Did you get that? Execution starts with the first line â>â character. It means to execute the next instruction on the right side, and the right side instruction is âvâ. This means to execute down instruction. This continues as an infinite loop. Here I added some of its instructions.
- â+â Addition: Pop two values a and b, then push the result of a+b
- â-â Subtraction: Pop two values a and b, then push the result of b-a
- â*â Multiplication: Pop two values a and b, then push the result of ab
- â/â Integer division: Pop two values a and b, then push the result of b/a, rounded down. According to the specifications, if a is zero, ask the user what result they want.
- â%â Modulo: Pop two values a and b, then push the remainder of the integer division of b/a.
- â!â Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero.
- â`â Greater than: Pop two values a and b, then push 1 if b>a, otherwise zero.
- â>â PC direction right
- â<â PC direction left
- â^â PC direction up
- âvâ PC direction down
- â?â Random PC direction
- â_â Horizontal IF: pop a value; set direction to the right if value=0, set to left otherwise
Read complete language specifications here. 3D represented languages also built called âSuzyâ based on this language. Here below an example of finding factorial with Befunge language
&>:1-:v v *_$.@ ^ _$>\:^
Brainfuck
This language was invented in 1993, as an attempt to create the smallest possible compiler. This compiler allows only eight commands to write a program and operate based on memory cell which is also known as tapes. Here is the list of command Brainfuck supports.
- â>â Move the pointer to the right
- â<â Move the pointer to the left
- â+â Increment the memory cell under the pointer
- â-â Decrement the memory cell under the pointer
- â.â Output the character signified by the cell at the pointer
- â,â Input a character and store it in the cell at the pointer
- â[â Jump past the matching ] if the cell under the pointer is 0
- â]â Jump back to the matching [ if the cell under the pointer is nonzero
Here below how hello world application implemented in Brainfuck language.
1 +++++ +++ Set Cell #0 to 8 2 [ 3 >++++ Add 4 to Cell #1; this will always set Cell #1 to 4 4 [ as the cell will be cleared by the loop 5 >++ Add 4*2 to Cell #2 6 >+++ Add 4*3 to Cell #3 7 >+++ Add 4*3 to Cell #4 8 >+ Add 4 to Cell #5 9 <<<<- Decrement the loop counter in Cell #110 ] Loop till Cell #1 is zero11 >+ Add 1 to Cell #212 >+ Add 1 to Cell #313 >- Subtract 1 from Cell #414 >>+ Add 1 to Cell #615 [<] Move back to the first zero cell you find; this will16 be Cell #1 which was cleared by the previous loop17 <- Decrement the loop Counter in Cell #018 ] Loop till Cell #0 is zero19 20 The result of this is:21 Cell No : 0 1 2 3 4 5 622 Contents: 0 0 72 104 88 32 823 Pointer : ^24 25 >>. Cell #2 has value 72 which is 'H'26 >---. Subtract 3 from Cell #3 to get 101 which is 'e'27 +++++ ++..+++. Likewise for 'llo' from Cell #328 >>. Cell #5 is 32 for the space29 <-. Subtract 1 from Cell #4 for 87 to give a 'W'30 <. Cell #3 was set to 'o' from the end of 'Hello'31 +++.----- -.----- ---. Cell #3 for 'rl' and 'd'32 >>+. Add 1 to Cell #5 gives us an exclamation point33 >++. And finally a newline from Cell #6
This can be represented in one line as follows.
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Piet
As you see it, it is a programming language where the programmer needs to color a grid instead of coding words. Pointer used to move around the bitmap image and execute command relevant to each color code. There are twenty colors used to represent command and white color does not represent any operation. when the pointer tries to enter a black region, the rules of choosing the next block are changed instead. Here below the sample program to print âPietâ.
Malbolge
Last but not least, this language is known as âProgramming from hellâ. The idea is that programming should be hard. Therefore, there is no point in discussing language syntax any further. An interesting fact of this language is that even the inventor of this language could not write a program by himself. However, Here an example program of hello world in Malbolge language.
(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc
Conclusion
I have listed down below other programming languages that I have found for further reading. An interesting fact about most of these languages was these are Turing complete, meaning you can implement any computer program that other programming languages can do. Even though these programming languages seem useless, it opens our minds to look at things differently.
Hope you enjoy reading this article. If you have any comment, you can find me on Twitter. Follow me for more interesting stories. Feel free to comment down your thoughts. See you in another article. Cheers :)
Weird Programming Languages That You May Have Not Heard was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.