ElixirScript

Motivation and Status

I would love to have some tooling akin to ClojureScript and Om, but based on Elixir rather than Clojure. Anyone who is asking "Why would I want this?" should watch ClojureScript: Lisp's Revenge. In this video, David Nolen shows off a large number of things that ClojureScript can do (and an "ElixirScript" could do).

So, a few months ago, I posted a note to elixir-lang-talk. It turns out that I wasn't the only person around that liked the idea. Various folks floated ideas (e.g., possible data paths), critiques, etc.

Bryan Joseph had already been doing some work in this area and decided to take on the challenge of creating ElixirScript. On 2015.0601, he released Version 0.5.0 of ElixirScript. Here is an overview of the current data flow, starting with Elixir source code:

  • Convert to Elixir AST, using Elixir's quote Special Form.
  • Convert to Spider Monkey AST, using custom code.
  • Convert to JavaScript code, using escodegen.

Based on a discussion with José Valim, Peter Hamliton, and Vincent Siliakus, Bryan is also looking into an alternative data flow:

  • Convert to Elixir AST, using Elixir's quote Special Form.
  • Convert to Erlang AST, based on the (private) :elixir module.
  • Compile to Erlang Core AST, using compiler:forms/2.
  • Compile to JavaScript, using LuvvieScript.

Here's a summary of his status, edited from assorted emails. Follow related threads on elixir-lang-talk for current information.

Notions and Notes

Here are some random notions and notes, in no particular order...

ClojureScript

It may be possible and useful to take advantage of ClojureScript during the ElixirScript development process. For example, could we create an AST that (part of) the ClojureScript tool chain can digest? If so, this might let us concentrate on Elixir parsing at first.

David Nolen said (on #clojurescript) that there are few difficulties (in interfacing to Google Closure) if you're already on the JVM and that you can be pretty successful without deeper integration into Closure. However, it's still early days, even for ClojureScript; David says: "We're just now past the basics (source mapping, module splitting), [so now] we can look at deeper stuff, like JS interop validation, externs inference, CommonJS/AMD/ES6 module support, etc."

ClojureScript supports Clojure's persistent data structures, but this is only of direct interest to ClojureScript programmers. However, David has also written a native JavaScript library (mori) which makes them more generally available. Finally, there's a version of Erlang (Erjang) that runs on the JVM, but I don't know how nicely it plays with Elixir, let alone Mix or Clojure.

Erlang

There have been various efforts (see below) to port Erlang to JavaScript. I would like to see ElixirScript take advantage of this work; ideally, work on supporting Elixir and Erlang could progress in parallel.

JavaScript

Node.js supports a rich and rapidly growing collection of tools for working with JavaScript. Bryan Joseph is currently using Node.js and escodegen to convert the JavaScript AST (created by Elixir) into JavaScript code. Other Node-based tooling may well find uses in other parts of the project.

Tasksonomy

It may also be useful to categorize the tasks. Here's a start...

  • Alligators
    • Support Elixir/Erlang data structures.
    • Support Erlang-specific VM functionality.
    • Translate ElixirScript code to JavaScript.

  • Ponies
    • Use Google Closure to optimize JavaScript.
    • Generate Source Maps for ElixirScript.
    • Play nicely with Elm, Om, etc.

  • Unicorns
    • Emulate Om (i.e., play nicely with React).
    • Integrate ElixirScript with Light Table.
    • Self-host the ElixirScript tool chain.


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r59 - 11 Apr 2016, RichMorin
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CFCL Wiki? Send feedback