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
22
u/AlexReinkingYale Halide, Koka, P Dec 31 '25
We're in r/ProgrammingLanguages, so I won't hesitate to comment on semantics. Memory safety and type safety are different things.
Java isn't memory-unsafe as a language. A null dereference has well defined behavior and does not corrupt program state. It throws an exception, which can be caught and handled. Whether a particular JVM uses memory-unsafe code is just an implementation detail.
The issue with null is (as you said) that it breaks the soundness of the type system. That's a serious issue, it's just not one that breaks the memory system. You can say Java is mostly type-safe except for null.
Here's a very interesting reference on the type system issues with null in Java and Scala. https://dl.acm.org/doi/10.1145/2983990.2984004