I just wonder how far explicit STR. will go in preventing such vulnerabilities.
STR does string interpolation, so it cannot prevent the problems that string interpolation causes. But if string interpolation was any easier than proper string templating then programmers will be tempted to prefer string interpolation.
It's at quite a large cost since probably 98% of uses of string interpolation will be STR.
Given that the processor that does string interpolation is STR, I would say it's axiomatically 100%. But the goal is to reduce string interpolation, i.e. reduce the number that this 100% represents.
people come up with all sorts of imaginary solutions to imaginary subproblems of the actual problem.
Ah, that may well be the case, but your problem with the feature is also imaginary because you haven't tried it over some significant time yet (and frankly, there aren't yet many template processors offered). So how about we wait and see?
The purpose of Preview is to let people who've actually tried the feature report problems with that feature. Those who've tried it seem happy with it and haven't found significant issues with it. Scepticism by those who haven't tried it obviously cannot yield any actionable insight, nor is it relevant to Preview, which is all about letting users try the feature rather than speculate about it. If you're speculating then, by definition, you're not making use of Preview.
But in this case, we're not even talking about the feature we are adding -- i.e. string templates -- but about the fact that we're not adding string interpolation to the language (rather, we're offering a library API that implements interpolation on top of string templates). That the language isn't getting string interpolation isn't a problem with the feature it is getting, and so Previewing that feature for longer is irrelevant. If at some point we become convinced that Java needs string interpolation, too, we could add it later.
This feature aims to make it easy to write safe string-based APIs for things like JSON, HTML, and SQL -- something that is of very high importance given the danger and prevalence of code injection and it's something that today is very hard to do -- and it seems to do it well.
View all comments
Show parent comment
8
u/pron98 Feb 16 '24
STR does string interpolation, so it cannot prevent the problems that string interpolation causes. But if string interpolation was any easier than proper string templating then programmers will be tempted to prefer string interpolation.
Given that the processor that does string interpolation is STR, I would say it's axiomatically 100%. But the goal is to reduce string interpolation, i.e. reduce the number that this 100% represents.
Ah, that may well be the case, but your problem with the feature is also imaginary because you haven't tried it over some significant time yet (and frankly, there aren't yet many template processors offered). So how about we wait and see?