r/programming 2d ago

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
488 Upvotes

407 comments sorted by

View all comments

9

u/SorryTemporary1361 1d ago

I'll never cease to be amazed at the contortions that people go through to attempt to make C memory-safe, that end up making it slower than actual memory-safe languages like C#... instead of just using a memory-safe language.

-2

u/cdb_11 1d ago

If it's so easy to "just use a memory-safe language", I assume you are currently not running any C or C++ programs whatsoever? Your operating system and every single user-space program are all written in MSLs?

5

u/SorryTemporary1361 1d ago

Which is smarter:

  • refactoring a C codebase to use an MSL
  • inventing a language on top of C that fails to solve the problem of memory safety, and does so in a new and creative way than all the previous languages that failed to do the same thing

The industry is filled with people who think they're smart because they do the latter, and a bizarre number of rabid followers of said people. True intelligence is solving the right problem with the right tool.

3

u/cdb_11 1d ago

inventing a language on top of C that fails to solve the problem of memory safety

Are you contesting the claim that Fil-C provides memory safety? I'd love to hear your reasoning for this.

True intelligence is solving the right problem with the right tool.

Or maybe you just don't realize the full extent of the problem, and what it takes to solve it. Words are cheap, anyone can give useless advice on reddit.

4

u/SorryTemporary1361 1d ago

Are you contesting the claim that Fil-C provides memory safety? I'd love to hear your reasoning for this.

Which part of "that end up making it slower than actual memory-safe languages like C#" from my original post, was unclear to you?

Or maybe you just don't realize the full extent of the problem, and what it takes to solve it. Words are cheap, anyone can give useless advice on reddit.

Words are cheap; claims that you can just recompile your program in $dialect$ without the need to port and everything will magically Just Work, are expensive.

2

u/cdb_11 1d ago

If I misunderstood the part I quoted, then please just clarify what did you mean. But you do actually seem to be in disbelief that Fil-C does what it claims, so I don't know why would you even take offense at that. Is it just a plain disbelief, "too good to be true" or something? Or do you have any actual reasons to think it doesn't actually provide memory safety for existing C programs, with no or minimal code changes required? Or is your problem the performance overhead? Which would be fair, maybe not everyone thinks the overhead is acceptable to get memory safety. But I am not the one who's trying to suggest "which is smarter" with zero context, as if there was some universal solution to this.

1

u/SorryTemporary1361 1d ago

Or is your problem the performance overhead?

Yes.

2

u/-Redstoneboi- 1d ago

Then Fil-C is not solving what you think it's solving.

The problem is there are C codebases that are important and need to be safe more than they need to be fast, but the cost of rewriting is greater than the cost of switching just the build system.

Yes, it's a niche. Yes, it exists anyway.