3 ms·
They didn't abandon the initial implementation, it's compiled to WASM then converted back to C I maintain what i said, i do not understand how this is a good i
by Kukumber 4y ago
They didn't abandon the initial implementation, it's compiled to WASM then converted back to C
I maintain what i said, i do not understand how this is a good idea
- fanf2 4y agoThe WASM is built from the second Zig compiler written in Zig, not the initial C++ compiler.
- dottedmag 4y agoThey did. WASM file is produced by compiling new compiler, one written in Zig.
- lifthrasiir 4y agoThat's not "converting back", because by going through WebAssembly you have restricted the language. As long as you have a correct wasm-to-C implementation this is a valid strategy to finish the bootstrap---you no longer depend on C, just WebAssembly.
- cogman10 4y agoNot quiet. They are compiling the current compiler to wasm and then using that compiler to build future versions of their compiler. In other words, they are doing the described rust approach but instead using a platform agnostic target instead of doing a binary. That allows them to build on any platform that has a C compiler and to use current language features without needing manually backport them. They could directly target C or C++ but that runs a greater risk of accidentally generating UB. Targeting a bytecode decreases that risk.
- jeremycw 4y agoI think you need to be a bit more humble on a topic that's clearly going over your head. Imagine a scenario where you are testing out a brand new RISC-V development board. The vendor has only provided a C compiler for this board as is often the case. You want to be able to use the zig language to write programs for your new development board but no zig compiler exists for this board yet. That means you need to compile the zig compiler from source. The latest version of the zig compiler is written in zig. Again you don't have a zig compiler so how will you compile the zig compiler from source? You need a way to go from C compiler to Zig compiler. That's what this is describing. It does not make sense to maintain two completely separate versions of the compiler. The "real" one written in Zig and the "bootstrap" one for compiling from C. So the zig source is compiled into WASM and stored in the repo. On a system with only a C compiler this WASM can be ran instead of a native zig binary. The WASM version can then be used to compile an actual native zig binary.