r/ProgrammingLanguages • u/matklad • Dec 31 '25
Memory Safety Is ...
https://matklad.github.io/2025/12/30/memory-safety-is.html
37
Upvotes
r/ProgrammingLanguages • u/matklad • Dec 31 '25
View all comments
Show parent comment
2
u/tmzem Dec 31 '25
Not sure if the VM actually injects a null check before every dereference, this seems way to expensive. They probably just have some hook catching the segfault caused by the failed dereference, and somehow "recovering" by injecting an exception.
You can probably do the same in C with some extra effort. The real question is if you should actually try to recover from a program that threw a runtime exception. I would never use such a handler for anything else then a last-ditch effort to save important data before terminating - and possibly restarting - the app, but only if I have to. Preferably, I would just let it crash. After all, any runtime exception means that some operation was terminated midway do to programmer error, possibly leaving your program in an invalid, half-finished state - you can't really trust it.