2 ms·
How about this definition? A compiler is anything which takes an input and produces some kind of executable code. That "executable code" might be machine code,
by mort96 9y ago
How about this definition?
A compiler is anything which takes an input and produces some kind of executable code. That "executable code" might be machine code, bytecode, another intermediate language (i.e WASM text, JavaScript, C, etc.), or whatever.
A transpiler is a form of a compiler which could be implemented as a parser + pretty printer; something where the semantics match an existing language, instead of having a complete "code generator". CoffeeScript is a good example of that, and so would for example a language which interpret Python code with braces and insignificant indentation, and outputs Python code without braces but with correct indentation.
One problem with this definition is that the C preprocessor would fall into the compiler category, because it produces C code. Maybe it would make sense to amend the definition of compiler to exclude macro languages; or maybe it would makes ense to include them in the overall compiler category and give them their own subcategory like transpilers.