Hacker News new | ask | show | jobs
by lynx23 934 days ago
The most awesome random submission I ever received was a BrainFuck compiler written in BrainFuck, by hand. Short story: I wrote a bf compiler in Emacs Lisp many many years ago. As a small testcase, I included a BrainFuck compiler in BrainFuck, which was written by a guy who wrote a C-alike to BrainFuck compiler so that he could implement his BF compiler in BF. That was a strange piece of code, about 6 pages of plain BF. A few years later, suddenly, I have this mail in my INBOX: A norwegian guy sent me a BF compiler in BF, written by hand. He was unsatisfied by the existing BF compiler, as it was generated. His implementation was about 6 lines of BF code. And it was a magnitude faster. Hats off to that guy!
1 comments

How do you implement a compiler in 6 lines of code, let alone 6 lines of BF code?
Whitespace is ignored in Brainfuck, so just write the compiler in brainfuck and then strip all but 6 newlines.
I think lines should be hard wrapped at around 100 or 120. Linus prefers 100 for example.
This is such a Brainfuck answer