digitalmars.D - [Semi-OT]: Sub-Millisecond Compilations with Zig's In-Place Binary
- Jacob Carlborg (19/19) Sep 29 2020 This is looks pretty darn awesome. The Zig self-hosted compiler
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (17/23) Sep 29 2020 I think it is a mistake to focus on raw batch compilation speed
This is looks pretty darn awesome. The Zig self-hosted compiler (which is far from complete in terms of language support) seems to be really fast. In the Zig compiler written in C++, most time is spent in LLVM optimizing and generating code. In the self-hosted compiler, everything is written in Zig: the frontend, the backend and linker. It seems it supports incremental compilation of the semantic phase, the code generation and the linking phase. It doesn't seem like it's currently using incremental lexing or parsing. It doesn't even need to relink everything, it just patches the executable in-place. This results in an incremental build taking around 0.5 milliseconds. Here's a video showing this feature [1]. This is something that D should have, including incremental lexing and parsing as well. It's also a reason to keep the DMD backend. [1] https://www.youtube.com/watch?v=R5FKgi9BYyU -- /Jacob Carlborg
Sep 29 2020
On Tuesday, 29 September 2020 at 07:59:17 UTC, Jacob Carlborg wrote:This is looks pretty darn awesome. The Zig self-hosted compiler (which is far from complete in terms of language support) seems to be really fast. In the Zig compiler written in C++, most time is spent in LLVM optimizing and generating code. In the self-hosted compiler, everything is written in Zig: the frontend, the backend and linker.I think it is a mistake to focus on raw batch compilation speed though. What matters most is what kind of feedback you get while editing your code. Decent programmers that complicated languages like D/C++/Rust appeal to don't need to iterate that frequently in terms of batch-compilation (which also can be sped up by using a cluster if it really matters). Yes, I am aware that many will argue that it is very beneficial during testing, but I'd argue that if you cannot run tests in parallell, then maybe they should be written differently. CPU prices are going to fall faster than the labour it takes to rewrite a compiler from scratch and so are cloud computing solutions... Where it does matter most is when you get fast compilation in combination with hot patching of running programs, like with Dart. Zig appears to be able to do that too using "hot swapping", but I have not tried Zig yet.
Sep 29 2020