Skip to content

soupglasses/opal-lang

Repository files navigation

Opal

A language inspired by Ruby and Elixir.

Compiles to BEAM for easy interoperatbility with other BEAM languages (Erlang, Elixir).

Example

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

Setup

# Choose one:
sudo apt install elixir # for Debian/Ubuntu
sudo dnf install elixir # for Fedora
sudo zypper install elixir # for SUSE/openSUSE

Running

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

Compile & Install

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

Testing

mix test --trace

About

Compiled language inspired by Ruby and Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •