Hacker News new | ask | show | jobs
by shoo 4764 days ago
brainfuck is a wonderful toy language. it is so simple - the entire language fits easily in your head, even though it is difficult to do anything useful with it.

more generally, compilers are fun to learn about. i found Jack Crenshaw's "Let's build a compiler" series a good starting reference and source of inspiration [1].

i built a brainfuck to GNU assembly compiler in brainfuck. to be able to write that compiler, i first built a higher-level macro language that could target brainfuck, and wrote a compiler for that. the macro language was implemented as a horrible DSL in python [2].

later i built an implementation in haskell that could parse and compile the macro DSL to brainfuck, so things ended up entirely python-free [3]. Haskell's Parsec parser combinator library was fun to learn about too [4].

[1] http://compilers.iecc.com/crenshaw/

[2] https://github.com/fcostin/abfc

[3] https://github.com/fcostin/abfc_hs

[4] http://www.haskell.org/haskellwiki/Parsec