EBQN
EBQN is an experimental implementation of a BQN
virtual machine in Erlang.
It can interpret BQN bytecode, and compile source expressions to bytecode via the BQN self-hosted compiler.
It is extremely slow! This seems due to BQN heap operations and Erlang mutability constraints. Using the JIT-enabled OTP 24 release is highly recommended.
There are several mitigations in consideration:
- Implement some (or all) of the BQN runtime in Erlang.
- Change from bytecode interpretation to AST generation via
erl_syntax
- Implement as a NIF via
rustler
Each of these strategies have pros and cons, and further investigation will happen.
For more information on the rationale behind this project, see the following blog post by Gordon Guthrie:
The BEAM needs an APL-y language
Installation
It is recommended to use EBQN by generating BQN bytecode with DBQN.
Usage
- Generate BQN bytecode:
$ ./misc/cerl /path/to/mlochbaum/bqn '{𝕩×10}'
- From EBQN root directory:
$ rebar3 shell
- Load the bytecode (using the bytecode from step 1):
1> rr(ebqn).
2> {St0,Rt} = ebqn:runtime().
3> {St1,F} = ebqn:run(St0,[[15,1,25,0,1,0,0,21,0,1,17,25],[ebqn_array:get(2,Rt#a.r),10],[[0,1,0,0],[0,0,3,3]]]).
4> ebqn:call(St1,F,1,undefined).
Build
$ rebar3 compile
Test
1> {St0,Rt} = ebqn:runtime().
2> ebqn_test:test(St0,Rt).