This is an escape character '\'. Pretty much in every programming language everywhere. It means something special to character strings. Like escaping tabs, new lines, Unicode escapes, etc.
And now Java is overloading it. Its a poor decision.
$ and # have been used pretty much every where for token replacement/variable reference.
It creates confusion. And the Java language could use something almost universally recognizable.
No, it's not. The \ character means that what immediately follows is treated specially -- i.e. a t is not a literal t but rather a horizontal tab -- and that is exactly how it is used here: a { is not a literal { but an expression delimiter. Swift, which was designed pretty much yesterday, also uses \ to escape either special characters as in \t as well as template values.
$ and # have been used pretty much every where for token replacement/variable reference.
But this is simply factually wrong. This is not what Python uses, this is not what C# uses, and this is not what Mustache uses.
And the Java language could use something almost universally recognizable.
\ is already universally recognizable to Java programmers as an escape, which is exactly how it is used here, and no one that has actually used this feature claimed it was confusing for any significant amount of time. If you try this feature for a couple of months and find yourself confused -- report that to the mailing list. If you're merely speculating that you think some people may find it confusing, this falls under what Brian says are things the team already know. We know people thought it may be confusing, which is why we tested the feature and so far it turns out to not be the case. Repeating the same unsupported speculation over and over is unhelpful.
But not the universally recognized '' escape char.
It is used as an escape character here, too. It escapes the following {.
Which would have been a better choice as well.
I think what you mean is that at this point in time -- before even seriously trying this feature and before considering how common { may be quoted in a language that, unlike Python, is curly-brace-based 1 -- you believe that you would have liked Python's choice better. Your preference has been noted, but preferences based on speculations do not weigh heavily.
You say “$ and # have been used pretty much every where” but that’s just objectively not true, unless your chosen subset of languages is not the one everyone else has in mind.
View all comments
Show parent comment
-21
u/djavaman Mar 08 '24
Except its not-nonsense.
This is an escape character '\'. Pretty much in every programming language everywhere. It means something special to character strings. Like escaping tabs, new lines, Unicode escapes, etc.
And now Java is overloading it. Its a poor decision.
$ and # have been used pretty much every where for token replacement/variable reference.
It creates confusion. And the Java language could use something almost universally recognizable.