
Show HN: A tiny brainfuck interpreter written in Rust - garritfra
https://github.com/garritfra/rustfuck
======
bjoli
Writing a bf interpreter or compiler is the first thing I do in a new
language. I have taken to representing the tape as a linked list which allows
for a one-pass optimizing pass whereamong other things +++ is turned into +3
and [-] into tape[cur] = 0.

I really liked reading the code since it is a problem I am familiar with.

Edit: here is a link with some simple optimizations
[http://calmerthanyouare.org/2015/01/07/optimizing-
brainfuck....](http://calmerthanyouare.org/2015/01/07/optimizing-
brainfuck.html)

All these are just pattern matching, which make them all simple!

~~~
garritfra
Very interesting. Thanks for the tip! Just out of curiosity: Do you host your
compilers/interpreters code somewhere? I'm currently involved in the
development of a language called Clio, and I'd like to compare other compiler
implementations in multiple languages/paradigms.

~~~
bjoli
I don't, but I got an idea for a BF compiler that also does partial evaluation
and some basic flow analysis :)

If you are interested in compilers, you should learn about guile scheme and
read the blog of one of the maintainers: wingolog.org

Guile has been taking big steps since the 1.8 days. Interpreter to bytecode
compiler to JIT and presumably onwards to AOT native code. Andy has been
writing a lot about it. He also worked a lot on the newer JavaScript engines,
so he has more input than just scheme :)

