3 ms·
If you'd like to see some tiny BF interpreters, have a look here: https://www.hugi.scene.org/compo/compoold.htm#compo6 https://www.hugi.scene.org/compo/compoold
by danparsonson 5y ago
If you'd like to see some tiny BF interpreters, have a look here: https://www.hugi.scene.org/compo/compoold.htm#compo6 https://www.hugi.scene.org/compo/compoold.htm#compo6
98 bytes, the smallest!
- aetherspawn 5y agoThe smallest compiler would copy the BF program to the end of this interpreter.
- Brian_K_White 5y agoOMG THIS This is my favorite answer to why this should or should not qualify as a compiler. If translating to c is a compiler then anything is a compiler and the term has no meaning at all.
- klyrs 5y agoThe word we need here is "trivial". A compiler is a function (or possibly, nondeterministic process) from source code in a first language, to source in a second language. The languages can be the same, for example, in the case of metaprogramming. The identity function is a trivial compiler. Calling it a non-compiler only serves to complicate the definition of compiler, with no discernable benefit.
- tylerhou 5y agoHow do you define "trivial?" I've created a new language called Brainfuck2 that is exactly the same as Brainfuck except the + symbol is replaced with a t. Clearly my compiler from Brainfuck2 => Brainfuck does not implement the identity function, and is less than 50 bytes.
- klyrs 5y agoAh, well that depends. The simplest definition is that the identity function is the only trivial compiler. One might take a more expansive view, that your Brainfuck2 language is homomorphic to brainfuck through a character-replacement table (though I must ask -- does your compiler introduce bugs if the original brainfuck source contains comments?[1]), and decide that character-replacement is trivial. You could even go further, and say that context-free token-replacement is trivial, at which point TFA counts as trivial compiler. That said, I'd estimate that most brainfuck compilers are trivial under that interpretation. [1] if you did it right, it's idempotent, which is about as close to trivial as a nontrivial function gets under the lens of symbolic dynamics, but I'm getting a bit far afield
- deleted 5y ago[deleted]