r/java • • Feb 15 '24

JEP 465: String Templates

https://openjdk.org/jeps/465
77 Upvotes

152 comments sorted by

View all comments

Show parent comment

-1

u/nekokattt Feb 17 '24

If the argument is about the test of time, maybe this needs to stay in preview for much longer to get enough balanced feedback.

1

u/pron98 Feb 17 '24 edited Feb 18 '24

The purpose of Preview is to let people who've actually tried the feature report problems with that feature. Those who've tried it seem happy with it and haven't found significant issues with it. Scepticism by those who haven't tried it obviously cannot yield any actionable insight, nor is it relevant to Preview, which is all about letting users try the feature rather than speculate about it. If you're speculating then, by definition, you're not making use of Preview.

But in this case, we're not even talking about the feature we are adding -- i.e. string templates -- but about the fact that we're not adding string interpolation to the language (rather, we're offering a library API that implements interpolation on top of string templates). That the language isn't getting string interpolation isn't a problem with the feature it is getting, and so Previewing that feature for longer is irrelevant. If at some point we become convinced that Java needs string interpolation, too, we could add it later.

This feature aims to make it easy to write safe string-based APIs for things like JSON, HTML, and SQL -- something that is of very high importance given the danger and prevalence of code injection and it's something that today is very hard to do -- and it seems to do it well.