Hacker News new | past | comments | ask | show | jobs | submit login
An esoteric programming language compiler on LLVM based on Brainfuck (github.com/brain-labs)
32 points by 8ctocat on Oct 14, 2017 | hide | past | favorite | 7 comments



LLVM seems like a huge dependency for something based around Brainfuck.

If I'm remembering correctly, the original Brainfuck interpreter was 250kb of ASM.


Brainfuck is simple enough that you could just write out the machine code directly in memory. I think that would make a really good exercise.

I made one based on GNU Lightning to JIT. Even that can be considered a pretty huge dependency:

https://github.com/cslarsen/brainfuck-jit

The interesting part is how slow a one-to-one translation of Brainfuck code to machine code will run without any optimizations. That's where the speed comes from, entirely based on those sweet optimizations. So writing one yourself is a rite of passage, like writing a Mandelbrot renderer.

The above project, from the looks of it, looks quite mature, and therefore interesting in its own right.


Nothing there I don't agree with.

I was more hoping someone might be able to shed light on why LLVM would be a good fit for something that it looks like it might be overkill for. Might just be it's what the authour/s are familiar with.


Sorry, you're memory is off by 3 orders of magnitude. 296 bytes

Anyways, I threw one together for WASM: https://github.com/serprex/brainwebfuckassembly


More than that, it was a compiler, not just an interpreter! [0] 240 bytes compiled, which is fantastic.

[0] https://gist.github.com/rdebath/0ca09ec0fdcf3f82478f


Jesus that is Huge, I've seen a Garbage Compacting Lisp Interpreter in only 8.4KB and a Full FORTH in 4.1KB (http://git.savannah.nongnu.org/cgit/stage0.git/tree/stage2) One would hope a Brainfuck interpreter isn't larger than those...


Why does this link to a fork that seems to be identical to the original? Would the mods please update the link to the source: https://github.com/brain-labs/brain




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: