Hacker News new | past | comments | ask | show | jobs | submit login

Null checks are effectively free on the JVM. One of the advantages of using null-as-real-null that is rarely discussed by functional programming fans is that null is well supported by the hardware. Just keep the bottom pages unmapped and an attempt to access a null pointer will trigger a hardware fault. If you don't do it that way then you have to do the null checks with branches in software, which bloats your code footprint and now with Spectre perhaps requires slower code too.



> Null checks are effectively free on the JVM

I don't want the bytecodes added. I have tracing I am doing and I need more predictable instructions. It's not just a performance issue.

Also, you should not assume cost of a JVM implementation of things based on your empirical evidence from a single, popular VM. For example, how does TeaVM translate it?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: