
Show HN: Synesthesia – Optimizing brainfuck compiler implemented as Nim macros - jeff_ciesielski
https://github.com/Jeff-Ciesielski/synesthesia
======
mratsim
I'm playing a lot with VM, interpreters, JIT and recently compilers in Nim.

Here is a JIT brainfuck VM:
[https://github.com/mratsim/jitterland](https://github.com/mratsim/jitterland)

Nim macros are extremely useful for assemblers and emulators as contrary to
many codebases which needs to use an intermediate code generation step via
text files [1][2][3] you can directly use them with type checking and all Nim
facilities while keeping an easy to read syntax:
[https://github.com/numforge/laser/blob/e898f027/laser/photon...](https://github.com/numforge/laser/blob/e898f027/laser/photon_jit/x86_64/x86_64_ops.nim)

[1]: Xbyak -
[https://github.com/herumi/xbyak/blob/v5.751/gen/gen_avx512.c...](https://github.com/herumi/xbyak/blob/v5.751/gen/gen_avx512.cpp)

[2]: NNPack + PeachPy -
[https://github.com/Maratyszcza/NNPACK/blob/af40ea7d/src/x86_...](https://github.com/Maratyszcza/NNPACK/blob/af40ea7d/src/x86_64-fma/relu.py)

[3]: Apache Milagro Crypto - [https://github.com/apache/incubator-milagro-
crypto/blob/d43a...](https://github.com/apache/incubator-milagro-
crypto/blob/d43ac938/version3/c/config64.py)

------
def-
Related:
[http://howistart.org/posts/nim/1/index.html](http://howistart.org/posts/nim/1/index.html)
[https://github.com/def-/nim-brainfuck](https://github.com/def-/nim-brainfuck)

------
fjfaase
Similar implementation in JavaScript:
[http://www.iwriteiam.nl/Ha_bf_online.html](http://www.iwriteiam.nl/Ha_bf_online.html)

