• Stars
    star
    716
  • Rank 63,241 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 15 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A JVM-based Erlang VM

Welcome to Erjang!

Build Status

Erjang is a virtual machine for Erlang, which runs on Java 7.

Building...

> ant alljar
...

alljar:
      [jar] Building jar: erjang-R16B01.jar

BUILD SUCCESSFUL
Total time: 20 seconds

Then, just run java -jar erjang-R16B01.jar

How does it work?

It loads Erlang's binary .beam file format, compiles it into Java's .class file format, and loads it into the JVM. It will eventually have it's own implementation of all Erlang's BIFs (built-in-functions) written in Java.

Does it work?

Yes! It does actually work.

  • It can boot Erlang/OTP to the Eshell (ej command).
  • There's a GUI console (ejc command) which supports ^G and line editing. The console still needs some work [Swing wizards welcome here].
  • Run Erlang distribution, tcp/ip, port commands (stdio to external processes).
  • You can run the compiler (c(foo) command in the prompt)
  • It runs mnesia with distribution across Erjang/BEAM nodes.
  • The HTTP packet parsers are in the tcp/ip stack, so mochiweb and webmachine can run (without crypto for now).
  • Larger systems like rabbitmq and riak can boot; and works for basic cases ... but it's not ready for prime time yet.
  • Etc. etc. Lot's of stuff work.
> java -jar erjang-R16B01.jar
** Erjang R16B01 **  [root:/Users/krab/erlang/r16b01] [erts:5.10.2] [unicode]
Eshell V5.10.2  (abort with ^G)
1> 2+3.
5
2> 1/0.
** exception error: an error occurred when evaluating an arithmetic expression
     in operator  '/'/2
        called as 1 / 0
     in call from apply/3 
     in call from shell:apply_fun/3 (shell.erl, line 883)
     in call from erl_eval:do_apply/6 (erl_eval.erl, line 573)
     in call from shell:exprs/7 (shell.erl, line 674)
     in call from shell:eval_exprs/7 (shell.erl, line 629)
     in call from shell:eval_loop/3 (shell.erl, line 614)
     in call from apply/3 
3>

There are still things that doesn't work: There are BIFs missing, or only partially implemented; we're quite careful to throw erjang.NotImplemented in BIFs (or branches thereof) which are not complete. Many OTP modules need NIFs or linked-in drivers that are entirely missing or only partly implemented. We do have experimental support for NIFs, so that may be improving soon.

What will it feel like to be running Erlang on the JVM?

Here is what to expect:

  • In Erjang, every node runs on a single heap, and so global GC will sometimes happen.
  • On the other hand, Erjang does not copy messages between processes -- they are simply shared, so sending large messages is significantly cheaper.
  • Over all, you will loose the predictability in behavior that Erlang has with regard to GC pauses, because Erlang can GC each process individually. Java GC continues to improve, so this might become less of an issue over time; but it will likely never go away.
  • My current tests indicate, that you can get better throughput in Erjang than BEAM, see this blog post, the graphs from google charts broke.
  • Erjang can run the "ring problem" at-par with BEAM, the Erlang virtual machine. If you let the JIT warm up, Erjang looks like it is faster than beam.
  • The big win is that Erjang is running on a VM that does dynamic compilation, selective inlining, and all the performance that comes from that.

Building

You should be able to do ant jar. You need Perl version 5.10 or later, or you'll be unable to build the interpreter.

Configuring

The only configuration you really need is to have an plain-old erlang installed, then Erjang will pick up the beam files using the $PATH to locate the erl binary, and then infer location of the beam files from there. For instance when booting ej

./ej
** Erjang R16B01 **  [root:/Users/krab/erlang/r16b01] [erts:5.10.2] [unicode]
Eshell V5.10.2  (abort with ^G)
1> 

You can see that it picked up the root from /Users/krab/erlang/r16b01. Alternatively you can pass an explicit -root /some/path to point erjang to a specific alternative erlang root.

Running

When running, it writes files named ~/.erjang/${module}-${CRC}.jar. Each of these contain the JVM equivalent of an erlang module loaded into Erjang.

These files also serve as a cache of files translated from beam -> jar. If something goes astray, it may help to remove the ~/.erjang directory forcing Erjang to recompile next time it runs.

Cheers!

Kresten Krab Thorup krab at trifork dot com

More Repositories

1

riack

C
17
star
2

secure-device-grid

Secure device-to-device communication solution for IOT
Swift
11
star
3

dlib

Core Dart Extension Library
JavaScript
9
star
4

TPA-fastlane-plugin-tpa

Ruby
9
star
5

sdm

Stamdata
Java
8
star
6

TriforkSwiftExtensions

Generic Trifork Swift Extensions
Swift
8
star
7

deltazip-erlang

Zip adaptation for archiving
Erlang
7
star
8

fastlane-plugin-prepare_build_resources

A fastlane plugin that prepares certificates and provisioning profiles for building and removes them afterwards.
Ruby
6
star
9

TIM-Android

Kotlin
5
star
10

dgws

Java
4
star
11

fastlane-plugin-translation

Ruby
4
star
12

deltazip-java

Zip adaptation for archiving
Java
4
star
13

trireg-cli

Command line interface for Trireg
Go
3
star
14

dart-jigsaw

Example Dart App
JavaScript
3
star
15

apoteksapp-documentation

Public repository containing external documentation about Apotekernes Service Platform (ASP) for pharmacy system providers.
Java
3
star
16

TIM-iOS

iOS framework for Trifork Identity Manager: SaaS Identity and Consent Management solution based on OpenID Connect standard that allows easy integration into all your applications.
Swift
3
star
17

fhir-translator

Executable jar that translates input FHIR resources using Google Cloud Translation
Java
3
star
18

fut-web-client

Web client for the FUT infrastructure - showcasing parts of the FUT API
TypeScript
3
star
19

TIMEncryptedStorage-iOS

iOS framework for KeyService feature of Trifork Identity Manager. The purpose of this framework is to encrypt and decrypt data based on a user provided secret or with biometrics. The framework exchanges secrets for encryption keys in safe way and stores encrypted data in the Keychain.
Swift
3
star
20

cheetah-development-infrastructure

Shell
2
star
21

dwm

Dart Web Machine
2
star
22

TPA-Gradle-Plugin

Gradle plugin for TPA
Groovy
2
star
23

eripedb

Erlang implementation of IP to ASN database
Erlang
2
star
24

cheetah-charts

Collection of helm charts used be the Cheetah Data Platform
Smarty
2
star
25

vectormap

Specification and reference implementations for vector maps
Erlang
2
star
26

TIMEncryptedStorage-Android

Kotlin
2
star
27

unsealed

An alternative to the seal.java library, but for modern VMs and with no 3rd party dependencies
Java
2
star
28

gradle-template

Starting point for Gradle projects at Trifork.
Shell
2
star
29

fhir-xsv-translator

Java
2
star
30

trireg2-api

2
star
31

fhir-bulk-data-import

1
star
32

TIM-Documentation

1
star
33

XMLCodable

Swift
1
star
34

dk-maternity-app-facade

1
star
35

FMKResources

1
star
36

dunit

Dart Unit Test Framework
Java
1
star
37

sdm2

Java
1
star
38

bemyndigelsesregister

NSI bemyndigelses service
Java
1
star
39

keycloak-smart-auth

Dockerfile
1
star
40

fmkclient.net

Example client written in C#, showing how to call GetMedicineCard on FMK
C#
1
star
41

TPA-fastlane-plugin-upload_symbols_to_tpa

Fastlane plugin that can be used to upload symbols to TPA
1
star
42

dk-maternity-facade-api

Java
1
star
43

AndroidBLE

Kotlin
1
star
44

fmk-dosis-til-tekst

Java
1
star
45

gototoday

The GOTO Today blog
Groovy
1
star
46

fastlane-plugin-static_assets

Generate code for buildtime-safe assignments of images
Ruby
1
star
47

mallorca-hackathon-2023

A distributed music player application
1
star
48

gradle-plugins

Mostly Trifork specific plugins for Gradle.
Groovy
1
star
49

emobility-client-ios

1
star
50

fmk-schemas

Java
1
star
51

TPA-SDK-Android

Android SDK for The Perfect App
Java
1
star
52

cheetah-example-flink

A repository for showing examples of how to use the data platform
Java
1
star
53

fmk-dosistiltekst-wrapper-nashorn

Java wrapper for fmk-dosis-til-tekst-ts java component, java 8 and above
Java
1
star