bryanjos

bryanjos

Rayscript: Erlang Abstract format to JavaScript

In my Lonestar Elixir presentation on Elixirscript I mentioned compiling from Beam files. About a 2 weeks ago, I started to play around with getting the Erlang Abstract Format from beam files. From there, I started thinking about turning that format into JavaScript. That project is rayscript

There are a couple of big advantages to doing so over Elixirscript’s implementation. The biggest one is that it could enable all languages on the Beam to convert code to JavaScript. Another is that compile time features, such as macros in Elixir, would not be a concern. Yet another would be that OTP should be easier to support as long as the beam files are available. I did some tests and was able to retrieve the format from beam files in both the Erlang and Elixir standard libs and convert to JavaScript. A question I get asked about a lot with Elixirscript are around processes. The problem isn’t that there is not an implementation for processes. One exists. The problem was one of integrating it within what already exists in Elixirscript. Starting from the beginning means that it will be a simpler task of adding it in.

The work done in Elixirscript helps a lot here. Most of what is there now is modified from Elixirscript. There are a few new problems. The biggest one being around how to handle NIFs. Also, an old one around JavaScript interoperability.

Long story short, if we can implement all of the forms there, we might be in business. I’m currently looking for any help on the project. Especially from anyone who can help with implementation, may have experience with other Beam languages, or who would be interested in helping with whatever underlying JavaScript that would be needed.

Most Liked

OvermindDL1

OvermindDL1

Looks fascinating!

Well NIF’s and Ports sound like great integration points between Rayscript and javascript at least. ^.^

If you are curious in Elixir AST → Javascript compilation, there is an old project that did most of it at GitHub - synrc/shen: 🐉 SHEN: Erlang JavaScript Compiler · GitHub if you are curious about any code to swipe or so since that project is long-dead. :slight_smile:

Shen worked based on a parse_transform though, much different method.

bryanjos

bryanjos

Thanks! I’ve seen shen before, but I think I will look to see how they implemented tail recursion.

I started looking into the idea after looking more and more into bucklescript recently since I see that both Ocaml and Reason can both use it. I’ve been interested in OCaml for a while now for some things and started taking the dive into it.

Where Next?

Popular in Announcing Top

Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19834 141
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10789 141
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
dominicletz
Hi, I thought I had posted my library before but seems I hadn’t. The project is still in early stages but it’s growing and so I think it...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement