Code Monkey home page Code Monkey logo

elixirscript's Introduction

ElixirScript Documentation Build

The goal is to convert a subset (or full set) of Elixir code to JavaScript, providing the ability to write JavaScript in Elixir. This is done by taking the Elixir AST and converting it into JavaScript AST and then to JavaScript code. This is done using the Elixir-ESTree library.

Requirements

  • Elixir
  • Node or io.js (only for development)

Usage

ElixirScript can be used in the following ways:

  • If using as part of a project, you can add the following to your deps

      {:elixir_script, "~> 0.7"}

    From there you can either use the ElixirScript module directly or the mix command, mix ex2js

  • CLI Client

    You can download the latest release from the releases page and use the included ex2js escript.

Development

Clone the repo

git clone [email protected]:bryanjos/elixirscript.git

Get dependencies

mix deps.get
npm install

Compile

mix compile

Test

mix test

To build distributable tarball

mix ex2js.dist

`ex2js.tar.gz` will be in the `dist` folder

Usage

  usage: ex2js <input> [options]

  <input> path to elixir files or 
          the elixir code string if the -ex flag is used

  options:
  -o  --output [path]   places output at the given path
  -ex --elixir          read input as elixir code string
  -r  --root [path]     root path for standard libs
  -h  --help            this message

#Limitations

Not all of the Kernel.SpecialForms module is defined

The following aren't defined (yet):

  • __CALLER__
  • __ENV__
  • quote
  • unquote
  • unquote_slicing
  • super

Most of the Standard Library isn't defined yet

A lot of functions in the Kernel module are implemented. The Enum, Atom, List, Tuple, Logger, and Range modules are either fully defined are not complete. The rest still need to be implemented. Some modules like System or File may not be useful or function in the browser and may end up being only useful when using ElixirScript outside of the browser.

No Macro support

Not sure how this would be implemented right now, but looking for ideas.

else blocks are currently not supported on try expressions

Only because the translation of else haven't been figured out yet

Pattern matching works but is still limited

Currently pattern matching on bitstrings isn't supported, but for every other case that one would use pattern matching, it should work.

There are probably more that I'm forgetting. Check the issues for what's implemented and what still is needed.

Example projects

elixirscript's People

Contributors

bryanjos avatar bratsche avatar richmorin avatar

Watchers

Josh Adams avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.