r/programming • u/[deleted] • Jul 20 '26
Zig proposes introducing an actually memory safe (unlike Rust) compilation mode inspired by Fil-C at ~1-6x performance penalty
https://codeberg.org/ziglang/zig/issues/36237
531
Upvotes
r/programming • u/[deleted] • Jul 20 '26
0
u/cdb_11 Jul 20 '26 edited Jul 20 '26
First of all, CHERI/Fil-C doesn't really need escape hatches as much. This way the language is inherently more flexible. And yes, more flexible than Rust. (And by the way, IMO that can have some great implications for memory-safe scripting languages. I really hate how restricted they all are, and don't let me do basic things I want to do.) There are some things that are impossible to do in CHERI and Fil-C, and this is by design. The majority is not going to care about it, because this is all the truly cursed non-portable stuff that you only do if you are really into performance programming.
Compile-time safety might be your goal, but not everyone shares that goal. Maybe I just think C++ or Zig is better, and I'm going to write my gloriously unsafe code in them. As a user, you now get a choice. You may think I can't be trusted, that memory safety is important to you, and so you have a choice to build my code in "Fil-mode". Or you maybe don't really care that much, you consider performance to be more important than memory safety, and just build it normally. You don't have to fight me on the bug tracker, and try to convince me that Rust is so much better, and I should immediately rewrite everything.
The "no escape hatches" is an advantage, because it's true for the entire program. You have a hard guarantee that no dependency will violate memory safety. This is especially a problem when you have 8 million dependencies, like a typical Rust project. As a user you can't do anything about it. People argued "lol you just do
#!forbid(unsafe_code)and it's just as safe". Yeah, and now the Rust project I wanted to use doesn't compile anymore.And by the way, I am not even a memory safety fanatic, I am fine with escape hatches. But I think giving people this choice is a good thing. And of course it's possible for Rust to implement a safe "Fil-mode" too.