5 ms·
There is no fundamental difference between compilers, code formatters, preprocessors or transpilers. Anything that takes a program and outputs another program r
by Banana699 5y ago
There is no fundamental difference between compilers, code formatters, preprocessors or transpilers. Anything that takes a program and outputs another program related to it by some semantics is a compiler.
That said though, I do agree that calling an assembler like this (brainfuck is a kind of assembly) a compiler stretches things a bit, for an entirely different reason: usually there is some sort of a complexity threshold of the input language. The compiler has to at least maintain a symbol table for named entities (traditional assemblies has variable-like entities, macros and subroutines, the assembler has to keep track of all that). Brainfuck is completely linear, with no named entities at all. The "compiler" looks like a dumb string processor, just iterates over one buffer to transform it into another buffer, and doesn't maintain any sort of structures on the code being translated.
By the strict "compiler : program->program" definition, this doesn't matter. But my intuition holds that dumb string processing is a bit short of "true" compilation.
- xg15 5y ago> There is no fundamental difference between compilers, code formatters, preprocessors or transpilers. Anything that takes a program and outputs another program related to it by some semantics is a compiler. That is arguing semantics and, while not wrong, I think it muddies the waters: By that logic, sed and awk are compilers. In the end, only machine code can be executed, so you'll need something at the end of your chain that produces machine code or at least executes your DSL in an interpreter loop. So I think a distinction between "compilers" that generate machine code and "compilers" that don't is worthwhile.
- dgb23 5y agoWhere do you draw the line? Is javac not a compiler?