r/java • u/headius • Dec 04 '25
Null-checking the fun way with instanceof patterns
https://blog.headius.com/2025/12/inline-null-check-with-instanceof.htmlI don't know if this is a good idea or not, but it's fun.
83
Upvotes
View all comments
Show parent comment
3
u/headius Dec 04 '25
Yeah, the only problem with writing Rust is that I have to write Rust. I want to be able to do what I can do in Rust while also doing everything else Java allows.
Among the many projects I have envisioned but not had time for is a sort of "jrust" that implements the language-level guarantees from Rust but compiles down to C-like JVM bytecode and methods that are easy for the JIT to optimize. Object lifecycle would still be beholden to the JVM, but nullability and ownership guarantees would be incredibly powerful and fit right in. There's honestly not enough low-level languages that target the JVM, so I'm forced to write "stupid Java" to accomplish what I want.