Fwd: String templates - JEP-459, JEP-465
Brian Goetz
brian.goetz at oracle.com
Sun Dec 29 17:30:26 UTC 2024
The following was received on amber-spec-comments.
The opinion expressed here (which can be paraphrased as "why don't you
just do string interpolation, it's safe and simple") is a familiar one,
and one which has been discussed over and over. The belief that there
are "no security concerns" with string interpolation is incorrect, and
"just do string interpolation" remains an anti-goal.
The author here might be correct that the intersection of "acceptably
secure" and "acceptably complex" is empty; in this case we will do
nothing. But we are continuing to explore this space to find something
that balances all the concerns.
-------- Forwarded Message --------
Subject: String templates - JEP-459, JEP-465
Date: Sun, 22 Dec 2024 01:27:16 +0100
From: Mariusz Lotko <mariusz.lotko at gmail.com>
To: amber-spec-comments at openjdk.java.net
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-experts/attachments/20241229/9a21ff4c/attachment-0001.htm>
More information about the amber-spec-experts
mailing list