4 ms·
LLVM seems like a huge dependency for something based around Brainfuck. If I'm remembering correctly, the original Brainfuck interpreter was 250kb of ASM.
by shakna 9y ago
LLVM seems like a huge dependency for something based around Brainfuck.
If I'm remembering correctly, the original Brainfuck interpreter was 250kb of ASM.
- csl 9y agoBrainfuck 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 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.
- shakna 9y agoNothing 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.
- __s 9y agoSorry, you're memory is off by 3 orders of magnitude. 296 bytes Anyways, I threw one together for WASM: https://github.com/serprex/brainwebfuckassembly https://github.com/serprex/brainwebfuckassembly
- shakna 9y agoMore than that, it was a compiler, not just an interpreter! [0] 240 bytes compiled, which is fantastic. [0] https://gist.github.com/rdebath/0ca09ec0fdcf3f82478f https://gist.github.com/rdebath/0ca09ec0fdcf3f82478f
- z29LiTp5qUC30n 9y agoJesus 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 http://git.savannah.nongnu.org/cgit/stage0.git/tree/stage2) One would hope a Brainfuck interpreter isn't larger than those...