3 ms·
That is an interesting edge case. I might amend my definition based on 'ease of translation' arguing that e.g. webassembly text and macro-less x86 assembly are
by rocqua 9y ago
That is an interesting edge case. I might amend my definition based on 'ease of translation' arguing that e.g. webassembly text and macro-less x86 assembly are so close to bytecode as to be equivalent.
In the end though, it seems hopeless to keep a sharp distinction definition of transpilers or compilers for that matter. Would something that turns WebAssembly text into WASM binary qualify for a compiler? Does an x86 assembler qualify? What about headless browsers that create screenshots?
- mort96 9y agoHow 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.