Comments by "" (@pierreollivier1) on "An Optimization That Is Impossible In Rust" video.
-
8
-
As a Zig longtime user, I've never used it on Windows, but I have to agree with you, on everything except for the memory efficiency, while Rust can like any compiled languages be used to write very memory efficient code, there is often a high skill barrier in front of it, the lack of a stabilized allocator_api certainly doesn't help Rust. From my experience being mainly a C developer, I would say that Zig is a great middle ground for high performance software. Rust can be but sometimes the added time of development and the additional complexity required to prove to the compiler that everything is safe, aren't worth the safety benefits, a lot of software doesn't need to be airtight safe, those who do should obviously try Rust first, but Zig is a good middle ground, as @maledil1 said technically both C and Zig offer the same level of "safety" but from experience I've built a strong opinion that the main reason why C is so problematic is because it lacks a lot of the ergonomics of modern languages, and the tooling certainly doesn't help there too. Zig just like Rust is trying to improve on that by taking a slightly different approach. Rust enforces correctness with a combination of a strong type system, strong static analysis tools, and an airtight semantic that's meant to prevent developers from being able to compile erroneous code. Zig does I would say 50% of that, and the rest requires the developer to be extra explicit which I find to be a great middle ground, because a lot of "unsafe" pattern in Zig are very verbose on purpose to make, it clear to the reader that this code may need more attention. This makes fixing bug so much easier than in C because it's really easy to see block containing tons of cast, and memory access, and it focuses the attention. On top of that they offer a wide array of great tools to help you catch bugs early, the testing framework, the debug allocators that help to catch use after free, double free, the optional semantic, and 99% of C UB are replaced by Zig panics, with stack trace. Technically in C you can enable all of what I've mentioned too, but the point is that this is not a default, and C still relies on UB unless asked otherwise. Plus even with everything enabled the tooling is still inferior and the debug ability is really not good.
But I think you are wise to keep on using Rust, it's should definitely be used over C, but as a friendly suggestions you might want to wait a few years and revisit Zig once it's a bit more stable :)
3
-
2
-
@Gigasharik5 Not exactly, they are implementing their own backend, currently the intent is to dramatically improve compilation speed in debug mode with very few optimization, and it's also why they wrote their own linker to not depend on lld, all of that is to offer faster debug build and also implement incremental compilation, remove the dependency on LLVM which is a big deal for many people, improve the modularity by making LLVM just an optional dependency, and in the long run they want to offer a new platform for white paper folks to implement their research in order to benefit from top of the line research and optimization. The problem with LLVM is that despite the fact that it can be used theoretically by any language, you still have to lower your language to an IR that was and still is designed to be optimal for C/C++ semantic, which is a problem because languages like Zig or Rust offers way more detailed and tailored semantic that has to be dumbed down or lower in a way that resemble C/C++. LLVM has also some blindspot that for example lead to the removal of async in Zig, it's also causes many bug reports in the zig project that stem from LLVM which takes time off the maintainers who need to investigate to rule out that it's not a problem from their compiler.
1
-
1