It does and is a tricky subject that also includes JIT and escape analysis as well as you mentioned compiler elides.
I can answer the second part: you profile for your performance needs, deployed architecture (eg cpu) etc.
I’m going to ignore Valhalla at the moment but in most cases simple code more often ends up running faster because the JIT can be trained faster. Less code paths. Immutable code inherently has less code paths.
View all comments
Show parent comment
4
u/agentoutlier Sep 18 '26
It does and is a tricky subject that also includes JIT and escape analysis as well as you mentioned compiler elides.
I can answer the second part: you profile for your performance needs, deployed architecture (eg cpu) etc.
I’m going to ignore Valhalla at the moment but in most cases simple code more often ends up running faster because the JIT can be trained faster. Less code paths. Immutable code inherently has less code paths.