3 ms·
>How is it better? Much more older and common use and association (even their own "Java EE Expression Language" uses it), and not confused with escaping a char
by coldtea 3y ago
>How is it better?
Much more older and common use and association (even their own "Java EE Expression Language" uses it), and not confused with escaping a character (like \n, \t) etc.
Pricinple of least surprise, avoiding NIH, and stuff.
- pron 3y ago> Much more older and common use and association (even their own "Java EE Expression Language" uses it) That was one of the main reasons not to use it; even in JS templating libraries use different syntax from that of the language's $ (see my other comment). > and not confused with escaping a character (like \n, \t) etc That would not be a confusion at all but the very point: \{ is just like \n or \t, i.e. gets a special interpretation rather than a literal one. > Pricinple of least surprise \ in Java is standard for that purpose (special interpretation in a literal); it is $ that is foreign. > avoiding NIH That is not so much of a principle, although it could be if the language was rejecting some otherwise universal choice, only that's not the case here at all. Of the other popular language with either a similar feature to Java's string templates or with string interpolation -- JS, Python, PHP, C#, and Ruby -- only JS and PHP use $ (and only PHP uses $ with the "shell" shortcut of $x). Or, if you only want to look at the "big three" -- JS, Python, and Java -- each has a different syntax from the other two, and only one uses $. Even if you look at all programming languages in the world, only a minority of programmers using a language with string templates and/or string interpolation use one where $ is used for the value syntax. Not only is it not a near universal choice, it's a minority choice.
- deleted 3y ago[deleted]