Sunday, October 23, 2011

Potion - a language of dots

Potion is a little language and runtime by why the lucky stiff. Not much potion can be found from the net, so I wanted to conjure some. Check my Church numerals implementation from github: https://github.com/avuori/Churchpotion.

In many ways conjuring potion feels like writing Python and, not surprisingly, Ruby, but there are differences. One of the most distinctive syntactical feature is that in Potion dot is not used as a separation of an object and a message as in many object oriented languages, but rather, as in prose, as an indication of the end of something. 

Potion is a language of dots, and that becomes quickly apparent, as one ends up ending nested blocks of potion with several dots...... Though in some potion recipe it was mentioned that there is a convenience method of using a single underscore to end nested blocks of code to avoid the trail of dots. To me however, "dotting" was a delightful practise, like sprinkling salt into my sweet potion to make it perfect.

Potion is jitted to machine code before execution. Before that potion is compiled to an intermediate bytecode format (what seemed like a register-based virtual machine code). You can get the Potion implementation from github: https://github.com/fogus/potion. I think in some fork I saw a REPL as well but I did not try it.

A final tip: If you want to compile Potion runtime in Linux, you may need to create a symlink /lib/libdl.so -> /lib/libdl.so.2.

I discovered Potion from a fogus' post - be sure to check that as well!