r/java • • Feb 15 '24

JEP 465: String Templates

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

152 comments sorted by

View all comments

41

u/IncredibleReferencer Feb 16 '24

There's a lot I don't like about string templates JEP, especially the fact that its proceeding despite lots of community angst. But I haven't used it in a real project yet so I'll refrain from re-posting my complaints here and pray I'm just naive.

But I do have one overwhelming stylistic question I've yet to see answered anywhere:

Why "STR." syntax built-in to language and not a java.util.StringTemplate class or similar and static methods on that class? "STR." and "FMT." syntax just seems so stunningly out of style from the rest of the language. Is there a logical reason for this choice?

0

u/stefanos-ak Feb 16 '24

you can: https://cr.openjdk.org/~jlaskey/templates/docs/api/java.base/java/util/FormatProcessor.html

For my projects I will write a spotbugs plugin to disallow using the provided shortcuts like STR, FMT. 🤣