Giter Club home page Giter Club logo

truffle-erlang's Introduction

TruffleErlang

TruffleErlang is an experimental implementation of the Erlang programming language built on GraalVM.

⚠️ This is a research prototype at an early stage.

Introduction

Unlike most implementations of Erlang, we choose Core Erlang as the input language. Core Erlang is an intermediate representation between Erlang and BEAM bytecode. Its detailed grammar can found in Core Erlang 1.0.3 language specification.

We make use of the Truffle language implementation framework to improve the runtime performance of Erlang. The principle of Truffle is elaborated in the PLDI'17 paper Practical Partial Evaluation for High-Performance Dynamic Language Runtimes.

Currently, a limited set of features is implemented for experimental purposes:

  • supports common data types: integers, floats, atoms, binaries, tuples, lists, funs
  • follows the Erlang conventions:
    • [a,b] is a shorthand for [a|[b|[]]], just like cons in Lisp
    • $char is interpreted as an integer of its Unicode code point
    • "string" is interpreted as a list of their Unicode code points
    • true and false atoms are used to denote boolean values
  • implements pattern matching with case
  • performs tail call elimination to avoid stack overflow
  • implements operators as built-in functions in the erlang module
    • arithmetic: + - * / div rem
    • logic: not and or xor
    • comparison: == /= =< < >= > =:= =/=
  • supports io:get_line and io:format for standard I/O
  • implements a half-baked actor model using Akka on JVM

Usage

First, make sure you have installed GraalVM and set $JAVA_HOME to point to the directory of GraalVM.

Note that the input language of our interpreter is Core Erlang. In order to execute Erlang source code, you should first compile it to Core Erlang using erlc. Then you can just use Gradle to build and run our interpreter.

erlc +to_core source.erl
gradle run --args source.core

The main/0 function in Core Eralng source code will be automatically executed.

Codename: Jiro

You may find the codename "Jiro" everywhere in our source code. It is a wordplay: Erlang is homophonous with the Chinese word "二郎" while the same characters read Jirō in Japanese, which indicates that Jiro is another implementation of Erlang. By the way, Jiro can also be interpreted as a Java Implementation of Erlang/OTP.

truffle-erlang's People

Contributors

yzyzsun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hellblazer

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.