A language inspired by Ruby and Elixir.
Compiles to BEAM for easy interoperatbility with other BEAM languages (Erlang, Elixir).
module Fibonacci do
fn fib(0) do 0 end
fn fib(1) do 1 end
fn fib(x) do
fib(x - 1) + fib(x - 2)
end
end
# Choose one:
sudo apt install elixir # for Debian/Ubuntu
sudo dnf install elixir # for Fedora
sudo zypper install elixir # for SUSE/openSUSE
Run a file:
$ mix opal examples/the_answer.opal
42
Compile a file:
mix opal --compile examples/the_answer.opal
Run code directly from Elixir:
$ iex -S mix
iex(1)> Opal.run("fn the_answer_to_everything() do 42 end the_answer_to_everything()")
42
MIX_ENV=prod mix do escript.build + escript.install
This will install opal to ~/.mix/escripts/opal
. Ensure ~/.mix/escripts
is in your $PATH
.
To uninstall:
MIX_ENV=prod mix escript.uninstall opal
mix test --trace