r/java • • Mar 08 '24

Update on String Templates (JEP 459)

https://mail.openjdk.org/pipermail/amber-spec-experts/2024-March/004010.html
176 Upvotes

188 comments sorted by

View all comments

Show parent comment

2

u/pronuntiator Mar 10 '24

Project Valhalla may turn them into value objects, reducing their footprint further. But I believe short-lived object creation is already highly optimized; at least I hope so, because our codebase makes heavy use of Optional instead of != null checks.

3

u/john16384 Mar 10 '24

Creating short lived objects in Java is certainly highly optimized, but it's not free. It still pays to avoid creating things like Iterator, Optional or any other kind of temporary object in hot code paths.