(stress-free: fib-rec [n Int] Int
(if (
intro
Snabl initiatives goals to implement a purposeful embedded Speak interpreter in C++.
motivation
I fancy notify lines, almost despite build of utility. And you doubtlessly have a notify line, scripting is nice in the end of the corner. So you might perhaps likely as properly arrangement for it by utilizing a out of the ordinary foundation. That manner that it’s miles shimmering to capture a unhurried manner to lead obvious of paying upfront. This project is supposed to simplify implementing that plan; by offering a flexible, modular framework for implementing interpreted languages in C++.
blueprint
The VM is register essentially based totally with sequential allocation and runs 64-bit bytecode. The evaluation loop is implemented using computed goto for performance causes, which manner that the space of accessible operations is mounted at library assemble time. States and frames are slab dispensed, reference counted and handed as raw pointers. Forms and values are designed to be (cheaply) handed by mark. The reader makes employ of recursive extent and is designed to be easy to customize/lengthen.
syntax
Parens are passe for calls handiest, brackets for vectors.
pickle
The codebase is drawing shut 2
kloc. Currently verifying and tweaking the blueprint to enhance performance in accordance with preliminary profiling. Error checking peaceable leaves plenty to desire for.
setup
Building the project requires a C++17-compiler and CMake, the following shell spell builds and starts the REPL:
$ cd snabl
$ mkdir invent
$ cd invent
$ cmake ..
$ invent
$ ./snabl
performance
bench
returns elapsed time in milliseconds for specified preference of repetitions. The original performance focal point is identifying and fusing bytecode patterns.
First up is total recursive Fibonacci, Python3 takes 233
ms on the the same machine.
(bench 100 (fib-rec 20))
1105
Subsequent tail recursive, Python3 takes 105
ms on the the same machine.
(stress-free: fib-tail [n Int a Int b Int] Int
(if (z? n) a (if (=n 1) b (fib-tail (dec n) b (+ a b)))))
(bench 10000 (fib-tail 70 0 1))
577
enhance
Whilst you wish to enhance Snabl and help me employ beyond regular time and vitality on evolving the project, please have in suggestions a donation in Bitcoin 3Qv3GdBCabkAustonEoEv63mVXMS8htiB5
or Ether 0x5BD559b709800731324e32eC512d786987DAdb0F
.
coder/mentor for hire
I’m for the time being available for hire.
A ways-off or relocation within Europe.
Send a message to codr7 at protonmail and I could get lend a hand to you asap.