News for hackers. Stuff that matters.
Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @06:54PM (#47811446)
The issue with Fil-C is that it's runtime memory safety. You can still write memory-unsafe code, just now it is guaranteed to crash rather than being a potential vulnerability.

Guaranteed memory safety at compile time is clearly the better approach when you care about programs that are both functionally correct and memory safe. If I'm writing something that takes untrusted user input like a web API memory safety issues still end up as denial-of-service vulns. That's better, but it's still not great.

Not to disparage the Fil-C work, but the runtime approach has limitations.

Re:A simplified model of Fil-C by pizlonator on Friday April 17, 2026 @07:02PM (#47811512)
> write memory-unsafe code, just now it is guaranteed to crash

If it's guaranteed to crash, then it's memory-safe.

If you dislike that definition, then no mainstream language is memory-safe, since they all use crashes to handle out of bounds array accesses

Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @07:25PM (#47811688)
I don't think that's a useful way of thinking about memory-safety - a C compiler that compiles any C program to `main { exit(-1); }` is completely memory-safe. It's easy to design a memory-safe language/compiler, the question is what compromises are being made to achieve it.

Other languages have runtime exceptions on out-of-bounds access, Fil-C has unrecoverable crashes. This makes it pretty unsuitable to a lot of use cases. In Go or Java (arbitrary examples) I can write a web service full of unsafe out-of-bounds array reads, any exception/panic raised is scoped to the specific malformed request and doesn't affect the overall process. A design that's impossible in Fil-C.

Re:A simplified model of Fil-C by wren6991 on Friday April 17, 2026 @10:36PM (#47812682)
You need to distinguish safety properties from liveness properties.
Re:A simplified model of Fil-C by dzaima on Friday April 17, 2026 @07:36PM (#47811762)
Then you run into the problem of infinite loops, which nothing can prevent (sans `main { exit(-1); }` or other forms of losing turing-completeness), and are worse than crashes - at least on crashes you can quickly restart the program (something something erlang).

try-catch isn't a particularly complete solution either if you have any code outside of it (at the very least, the catch arm) or if data can get preserved across iterations that can easily get messed up if left half-updated (say, caches, poisoned mutexes, stuck-borrowed refcells) so you'll likely want a full restart to work well too, and might even prefer it sometimes.

Re:A simplified model of Fil-C by wakawaka28 on Friday April 17, 2026 @07:32PM (#47811731)
I don't think runtime error handling is impossible in Fil-C, at least in theory. But the use cases for that are fairly limited. Most errors like this are not anticipated, and if you did encounter them then there's little or nothing you can do useful in response. Furthermore, runtime handling to continue means code changes, thus coupling to the runtime environment. All of these things are bad. It is usually acceptable to fail fast and restart, or at least report the error.
Re:A simplified model of Fil-C by pizlonator on Friday April 17, 2026 @08:21PM (#47812016)
I could have made Fil-C’s panic be a C++ exception if I had thought that it was a good idea. And then you could catch it if that’s what tickled your pickle

I just don’t like that design. It’s a matter of taste

Re:A simplified model of Fil-C by wakawaka28 on Friday April 17, 2026 @11:42PM (#47812954)
That's actually not a bad idea, since apparently it can be used for whole operating systems. But certainly, if you started doing that, any code using the exception would need to be exclusive to Fil-C to benefit from that.
Re:A simplified model of Fil-C by ori_b on Friday April 17, 2026 @07:24PM (#47811680)
By that token, Rust is also memory unsafe: array bounds checks and stack overflow are runtime checks.
Re:A simplified model of Fil-C by p1necone on Friday April 17, 2026 @08:04PM (#47811925)
Why are you talking like this is black and white? Many things being compile time checkable is better than no things being compile time checkable. The existence of some thing in rust that can only be checked at runtime does not somehow make all the compile time checks that are possible irrelevant.

(Also I think the commenter you're replying to just worded their comment innacurately, code that crashes instead of violating memory safety is memory safe, a compilation error would just have been more useful than a runtime crash in most cases)

Re:A simplified model of Fil-C by DetroitThrow on Friday April 17, 2026 @07:39PM (#47811790)
There are several ways to safely provide array bounds check hints to the Rust compiler, in-fact there's a whole cookbook. But for many cases, yep, runtime check.
Re:A simplified model of Fil-C by 100ms on Friday April 17, 2026 @07:08PM (#47811551)
Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @07:32PM (#47811730)
https://play.rust-lang.org/?version=stable&mode=debug&editio...

Catch the panic & unwind, safe program execution continues. Fundamentally impossible in Fil-C.

Re:A simplified model of Fil-C by wakawaka28 on Friday April 17, 2026 @07:36PM (#47811764)
Seems like a niche use case. If it needs code to handle, it's also not apples to apples...
Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @07:50PM (#47811859)
It's an apple to non-existent-apple comparison. Fil-C can't handle it even with extra code because Fil-C provides no recovery mechanism.

I also don't think it's that niche a use case. It's one encountered by every web server or web client (scope exception to single connection/request). Or anything involving batch processing, something like "extract the text from these 10k PDFs on disk".

Re:A simplified model of Fil-C by wakawaka28 on Friday April 17, 2026 @08:03PM (#47811922)
Sure, it's not implemented in Fil-C because it is very new and the point of it is to improve things without extensive rewrites.

Generally, I think one could want to recover from errors. But error recovery is something that needs to be designed in. You probably don't want to catch all errors, even in a loop handling requests for an application. If your application isn't designed to handle the same kinds of memory access issues as we're talking about here, the whole thing turns into non-existent-apples to non-existent-apples lol.

Re:A simplified model of Fil-C by saghm on Saturday April 18, 2026 @01:03AM (#47813271)
The root comment here said this:

> All this "rewrite it in rust for safety" just sounds stupid when you can compile your C program completely memory safe.

All of the points about Rust were made in that context, and they've pushed back against it successfully enough that now you're trying to argue from the other side as if it disproves their point. No one here is saying that there's no point in having safer C code or that literally everything needs to get rewritten; they're just pointing out that yes, there is a concrete advantage that something in Rust has over something in C today even with Fil-C available.

Re:A simplified model of Fil-C by wakawaka28 on Saturday April 18, 2026 @10:43AM (#47816306)
There are many concrete disadvantages to writing things in Rust too, not to mention rewriting. But you are right, these are different solutions and they thus have different characteristics.

As for your "as if it disproves their point" stuff is wrong. The fact is, the reply to a comment in a thread is not a reply to a different one. You are implicitly setting up a straw man like "See, you are saying there are NO advantages to using Rust over Fil-C" and I never said that at any point. I also didn't say that you said that there was no advantage to using Fil-C.

Re:A simplified model of Fil-C by saghm on Saturday April 18, 2026 @11:07PM (#47821497)
My point is that no one here defending Rust is trying to say that Fil-C doesn't offer anything useful or claim that Rust is better in all circumstances. When one person says "A is strictly better than B", and some people respond "Here are some cases where you'd still get benefits from B over A", coming in and saying "A is better in these other circumstances" isn't saying anything that people aren't already aware of.
Re:A simplified model of Fil-C by wakawaka28 on Sunday April 19, 2026 @02:15PM (#47826346)
>coming in and saying "A is better in these other circumstances" isn't saying anything that people aren't already aware of.

Oh so you're a psychic now too? I think all kinds of people read these threads. Most of them probably aren't as aware as you're claiming, even the ones actively commenting on the topic.

Re:A simplified model of Fil-C by uecker on Friday April 17, 2026 @08:27PM (#47812057)
I do not know how Fil-C handles this, but it could raise a signal that one can then catch.
Re:A simplified model of Fil-C by jz391 on Saturday April 18, 2026 @12:28AM (#47813137)
Reminds me of a commercial project I did for my old University department around 1994. The GUI was ambitious and written in Motif, which was a little buggy and leaked memory. So... I ended up catching any SEGVs, saving state, and restarting the process, with a short message in a popup telling the user to wait. Obviously not guaranteed, but surprisingly it mostly worked. With benefit of experience & hindsight, I should have just (considerably) simplified it: I had user-configurable dialogs creating widgets on the fly etc, none of which was really required.
Re:A simplified model of Fil-C by zamadatix on Friday April 17, 2026 @07:24PM (#47811676)
.get() will bounds check and the compiler will optimize that away if it can prove safety at compile time. That leaves you 3 options made available in Rust:

- Explicitly unsafe

- Runtime crash

- Runtime crash w/ compile time avoidence when possible

Re:A simplified model of Fil-C by touisteur on Saturday April 18, 2026 @02:43AM (#47813676)
SPARK does static analysis (proof) of Absence of Runtime Errors (AoRTE).
Re:A simplified model of Fil-C by ngrilly on Saturday April 18, 2026 @11:49AM (#47816836)
Yes, but that requires eliminating aliasing and expressions with side effects?
Re:A simplified model of Fil-C by boredatoms on Friday April 17, 2026 @06:56PM (#47811462)
For some things the just-crash is ok, like cli usage of curl
Re:A simplified model of Fil-C by forrestthewoods on Friday April 17, 2026 @07:09PM (#47811560)
Rust also has run-time crash checks in the form of run-time array bounds checks that panic. So let us not pretend that Rust strictly catches everything at compile-time.

It’s true that, assuming all things equal, compile-time checks are better than run-time. I love Rust. But Rust is only practical for a subset of correct programs. Rust is terrible for things like games where Rust simply can not prove at compile-time that usage is correct. And inability to prove correctness does NOT imply incorrectness.

I love Rust. I use it as much as I can. But it’s not the one true solution to all things.

Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @07:37PM (#47811776)
Not trying to be a Rust advocate and I actually don't work in it personally.

But Rust provides both checked alternatives to indexed reads/writes (compile time safe returning Option<_>), and an exception recovery mechanism for out-of-bounds unsafe read/write. Fil-C only has one choice which is "crash immediately".

Re:A simplified model of Fil-C by uecker on Friday April 17, 2026 @08:28PM (#47812063)
What makes you think that one can not add an explicit bound check in C?
Re:A simplified model of Fil-C by tialaramex on Friday April 17, 2026 @08:41PM (#47812149)
It's trickier than it looks because C has mutable aliases. So, in C our bounds check might itself be a data race! Make sure you cope
Re:A simplified model of Fil-C by uecker on Friday April 17, 2026 @09:35PM (#47812436)
Depending on what you are doing, yes. But the statement I responded to "your only choice is crash" is certainly wrong.
Re:A simplified model of Fil-C by jstimpfle on Sunday April 19, 2026 @09:03AM (#47824009)
Bounds checks have nothing to do with data races. GP is right, you can add bounds checks. Either using macros or (in C++) with templates and operator overloading.
Re:A simplified model of Fil-C by tialaramex on Wednesday April 22, 2026 @11:51AM (#47865390)
Alas, in C or C++ you have mutable aliasing, so I'm afraid you do incur a potential data race because your bounds might alias. Be careful out there.

Also remember that in C++ you may get a reference in these cases and if you keep that reference rather than using it immediately now you also have a potential TOCTOU race because the reference was only valid when you did the bounds check.

Re:A simplified model of Fil-C by jstimpfle on Thursday April 23, 2026 @11:04AM (#47876588)
True, but you do incur potential data races _everywhere_. There's no relation to bounds checking specifically.
Re:A simplified model of Fil-C by tialaramex on Friday April 24, 2026 @11:42AM (#47891788)
Ah, maybe I should have made the example clearer

With mutable aliasing the length might change even though the data you care about did not, and so adding the check means incurring a race which did not previously exist and which certainly the naive C programmer cannot see...

We can definitely mitigate this in the type system for most real world scenarios, but you don't mitigate problems you don't know about, so knowing is what's important.

Re:A simplified model of Fil-C by omcnoe on Friday April 17, 2026 @08:35PM (#47812115)
If you can correctly add all the required explicit bounds checks in C what do you need Fil-C for?
Re:A simplified model of Fil-C by kimixa on Friday April 17, 2026 @09:43PM (#47812475)
Same reason any turing complete language needs any constructs - to help the programmer and identify/block "unsafe" constructs.

Programming languages have always been more about what they don't let you do rather than what they do - and where that lies on the spectrum of blocking "Possibly Valid" constructs vs "Possibly Invalid".

Re:A simplified model of Fil-C by uecker on Friday April 17, 2026 @09:25PM (#47812394)
For temporal memory safety.
Re:A simplified model of Fil-C by wakawaka28 on Friday April 17, 2026 @07:39PM (#47811794)
>And inability to prove correctness does NOT imply incorrectness.

And inability to prove incorrectness does NOT imply correctness. I think most Rust users don't understand either, because of the hype.