4 ms·
I'd say if it doesn't output bytecode, its a transpiler. In bytecode I'd include JVM, LLVM and actual machine code. There is some ambiguity for python, since py
by rocqua 9y ago
I'd say if it doesn't output bytecode, its a transpiler. In bytecode I'd include JVM, LLVM and actual machine code.
There is some ambiguity for python, since python files are transformed to python bytecode before being interpreted.
- xigency 9y agoSo Chicken Scheme uses a transpiler and not a compiler? What about Nim? I don't think that's s sufficient definition when these fully capable languages call their tools that output C code "compilers." Honestly, the article's definition with levels of abstraction seems reasonable. The languages I mentioned are high-level and C operates at a lower level of abstraction, therefore they use compilers.
- dom96 9y agoIndeed, Wikipedia also defines it this way. Compiling from Nim to C is moving from a high-level of abstraction to a lower level and so Nim is a compiler.
- kazagistar 9y agoWhy do they have to be mutually exclusive? Transpires are the subset of compilers that target high level languages.
- mort96 9y agoDoes that mean that a "compiler" which outputs the WebAssembly text format, relying on other tools to convert that to the WASM binary format, is a transpiler?
- Vendan 9y agoAnd how about a C "compiler" that outputs assembly, and relies on an assembler to generate machine code?
- rocqua 9y agoThat 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.