Potion (programming language)

potion is a tiny, fast dynamic, stack-oriented computer programming language with a JIT compiler, closures, continuations and exceptions, a Lua-based VM and an Io-based object model built around message passing, a MOP and mixins. It is technically a lexical-only Lisp-1 with two languages: one for code, one for data and it is written in under 10K lines of C.

History

potion was created by _why as last project in 2007 before his disappearance from the internet. He started playing with Lua's internals and reading stuff by Ian Piumarta and Nicolas Cannasse.

After _why's disappearance, a developer named Fogus took over maintenance until 2013.

In 2013 a group calling itself perl11 "(5+6=11)" with Reini Urban as lead developer took over potion development to be used as Virtual Machine for "p2", a planned implementation for Perl5 and Perl6. Both languages, potion and p2 are now developed together by perl11 developers. v0.1 was released on Oct 16th, 2013 on the perl11 github account.

Philosophy

"If you keep it small, fit the VM and the parser and the stdlib all into 10k lines, then it's no sweat."

Examples

Fibonacci sequence:

fib = (n):
  if (n < 2): n. else: fib (n - 1) + fib (n - 2).
.
n = argv(1) number
if (n<1): n=28.
("fib(",n,")= ", fib(n)) join say
# parrot example/fib.pir 40  3m36.447s
# perl   example/fib.pl  40  2m19.752s
# potion example/fib.pn  40  0m3.512s

Features

  • pure object-oriented based on prototypes
  • callcc/yield based exception handling in unportable assembler
  • Perl-like regular expressions (planned)
  • compacting inprecise garbage collecting supporting weak links
  • DLL/shared library dynamic loading on most platforms
  • introspection, reflection and metaprogramming
  • Actor-based concurrency
  • Coroutines
  • fast asynchronous IO
  • small virtual machine
  • higher-order functions