String templates - JEP-459, JEP-465
Mariusz Lotko
mariusz.lotko at gmail.com
Sun Dec 22 00:27:16 UTC 2024
Good evening,
I read all three JEPs of String Templates and I'm a bit surprised that
we need such a complicated feature.
I bet that most Java developers simply _expects_ simple string
interpolation, that they will be able to replace not-quite-readable
string concatenations like:
"This is " + some.strange().callsWith("an argument") + " the end"
with something like (I like JS version the most)
`This is ${some.strange().callsWith("an argument")} the end`
or
```
This is the multilne version
${some.strange().callsWith("an argument")}
the multiline end
```
At compiler level that would be "simply" replace to old-good
contatenation implementation which is StringBuilder calls.
No security concerns (other than with current + operator), no (hidden)
runtime penalties like the proposed FMT feature has to introduce.
"String Templates" as language feature opened for externding by the
libraries seem to me quite complicated. The benefit that we provide
templates built into the language does not seem to be attractive - why
should I use built-in templates instead of 3rd party
Velocity/JTwig/whatever else?
Best regards,
Mariusz Lotko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-comments/attachments/20241222/8208472d/attachment.htm>
More information about the amber-spec-comments
mailing list