Hacker News new | ask | show | jobs
by kjeetgill 1055 days ago
A ton of comments are missing the point of this complaining about list/map syntax etc. I'm not sure if the kotlin lazy addresses this.

The point is that static final variables interact especially well with the JIT's constant folding machinery. But lazy loading a constant necessitates that it can't be final: it's initially null until it's effectively final after the first lazy load. This finality is clear to the developer but not to the JVM.

This is introduces a way to implement lazy constants via a blessed class that solves this.

The article is pretty clear about what the point is — but does require some careful reading and context.

1 comments

The example used is the venerable Logger class from the log4j package. It seem implausible that imprecise constant folding would cause a measurable performance decrease when using that class. So to me the point is not clear. A more convincing argument would be before and after stats of a benchmark showing x% performance increase.
Your other points aside, venerable might not be the right word for a package notorious for one of the most impactful zero days in recent memory.