7 ms·
I'm a bit out of the loop on new Java features so I was reading https://en.wikipedia.org/wiki/Java_version_history https://en.wikipedia.org/wiki/Java_version_hi
by nabogh 3y ago
I'm a bit out of the loop on new Java features so I was reading https://en.wikipedia.org/wiki/Java_version_history https://en.wikipedia.org/wiki/Java_version_history
And string templates looked exciting to me. But after skimming
https://openjdk.org/jeps/430 https://openjdk.org/jeps/430
it sounds like they want to avoid backticks for "safety"? Like we can already use the plus operator to append strings why would it be any less safe to give us an ergonomic way to do that? Oh well, Java isn't exactly known for being ergonomic.
- 60secs 3y agoBackticks are used as literals in a lot of contexts, especially DBs. Overloading that behavior by default would likely blow up a lot of code and certainly violate the principle of least surprise.
- paulddraper 3y agoBy DBs, you mean MySQL :/ No one else has such an oddity
- coldtea 3y agoSQLite also features backticks as literals (though they're not the main option). And I fail to see how it's much of an oddity, as other RDBs use all kinds of BS for literals. SQL Server for example uses [square brackets]. If anything backticks have some history of being used for string literals in some languages (e.g. Javascript and Go), whereas in many others they are used for command substitution (which is not far removed from what a string literal combined with a processor does in Java).
- paulddraper 3y agoI consider them to be odd when ANSI SQL has perfectly workable identifier quoting. Different for the purpose of being different.
- scrame 3y agoyes and mysql has an enormous install base.
- lolinder 3y agoThe safety isn't in avoiding backticks, that's just syntax. The safety comes from requiring you to specify which template processor you're using for the template string, so it's just as easy to use the right processor (eventually, SQL."") as it is to use the wrong one (STR.""). Using STR."" instead of STR.`` is just an aesthetic choice, and one that I think makes sense for Java.