Hacker News new | ask | show | jobs
by alserio 1643 days ago
Isn't the point that you don't generally stuff your log of things that are only strings but of things that can become strings? (Asking since I know of your work with truffle)
1 comments

I assumed things like the names of resources that are already strings because you’re using them in the actual program?
A typical logger.info("user {} did the thing", user) can skip the actual string interpolation and user value stringification, if the log level is not > info. However, logger.info("user " + user + " did the thing") cannot avoid at least the execution of user.toString(), even after jit optimizations, unless the jit could prove that toString does not have side effects. But I don't believe the jvm jit tries to do that. Am I wrong?
If user is a string, then #toString() is a trivial method, will inline, and become a no-op.
However, if user happened be an user-defined User object it would be hard to guarantee that it could be inlined
Yes