Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Befunge considered hard to compile?

One of the design goals of Befunge was to be hard to compile. However, it is quite easy to interpret. One can write an interpreter in a conventional language, say C. To translate a Befunge program to equivalent machine code, one can hard-code the Befunge code into the C interpreter, and compile the resulting C program to machine code. Or does "compile" mean something more restricted which excludes this translation?

like image 431
Prateek Avatar asked Oct 02 '22 23:10

Prateek


1 Answers

To translate a Befunge program to equivalent machine code, one can hard-code the Befunge code into the C interpreter, and compile the resulting C program to machine code.

Yes, sure. This can be applied to any interpreter, esoteric language or not, and under some definitions this can be called a compiler.

But that's not what is meant in "compilation" in the context of Befunge - and I'd argue that calling this a "compiler" is very much missing the point of compilation, which is to convert code in some (higher) language to semantically equivalent code in some other (lower) language. No such conversion is being done here.

Under this definition, Befunge is indeed a hard language to convert in such a way, since given an instruction it's hard to know - at compile time - what the next instruction will be.

like image 114
Oak Avatar answered Oct 11 '22 13:10

Oak