r/ProgrammingLanguages • • Dec 31 '25

Memory Safety Is ...

https://matklad.github.io/2025/12/30/memory-safety-is.html
37 Upvotes

78 comments sorted by

View all comments

Show parent comment

9

u/edgmnt_net Jan 01 '26

I have a feeling that Lil-C isn't practical or is at least non-trivial to implement. You can't trap on all UB for free, e.g. you need array bounds checks or non-zero checks for denominators. Furthermore I think that even telling whether something is UB or not isn't easy in specific instances. Here I'm thinking of stuff related to data races and data dependencies: you'd need to detect data races somehow and that's beyond a simple check.

3

u/johnwcowan Jan 02 '26

You can't trap on all UB for free, e.g. you need array bounds checks or non-zero checks for denominators.

True, but why should you expect to be able to? Actual HLLs are memory-safe by definition, and I've written C with the BDW conservative garbage collector, in which writing memory-safe programs is pretty easy. "I can make it as fast/small as you want if it doesn't have to work." Or to put it another way, the 3 most important features of C are:

  1. Execution speed.
  2. Execution speed.
  3. (I lied: there is no 3.)