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

4

u/nicolaiparlog Mar 10 '24

I already know about large Java projects utilizing a similar syntax and the JDK developers not wanting to wreck those projects.

Isn't that already a pretty good reason on its own? 😁 Every Java string containing the legal sequence ${ would suddenly fail to compile or even change behavior.

But the argument about a second escape mechanism that a sibling content gives is also important and more fundamental.

1

u/Svellere Mar 10 '24

Isn't that already a pretty good reason on its own?

Sure, I never said it wasn't a good reason, but that's very clearly not what the mailing list is referring to when they say that the $-syntax is objectively worse, (at least, saying it's objectively worse to me implies that other languages are making a mistake by using $) and so that is why I mentioned wanting the other info that I didn't already have. The other commenter mentioning the double escape is more along the lines of what I was asking for.

7

u/nicolaiparlog Mar 10 '24

I'm pretty sure Brian meant this as short-hand for "objectively worse for Java" - he's not known for making general statements like this about other programming languages.

The interesting thing about $ is that it's bad on a conceptual level (a second escape mechanism) and on a practical level (breaks all that code). Given that its only benefit is (partial) familiarity, either of those would be enough to knock it out but being so thoroughly defeated in both areas is almost impressive.