score:0

a scala.xml.elem would be constructed which had the string contents represented as an arraybuffer, chopped up for every { } substitution. i'm certainly no authority but i believe what would happen is that there's a little extra overhead in construction the object and then getting the children and concatenating them together at runtime but, at least in this example, as soon as it's passed to the sql function which then extracts the string it wants (or perhaps this would be done with an implicit) the elem object would be discarded so there'd be a little extra memory usage, but only briefly.

but in the bigger picture, i don't think it's performance that would hinder the adoption of this solution but i guess a lot of people would be uncomfortable abusing xml in this way by using a made-up tag. the problem would be with other users reading the code later trying to figure out the semantic meaning of the tag... only to find there isn't one.

score:0

the example you give is almost certainly not doing string concatenation, it's creating parameterized sql statements (probably via jdbc's preparedstatement).

ironically, the lack of easy string concatenation is probably slightly encouraging best practices in this case (although i certainly wouldn't use that as an argument either way on the topic).

score:0

if you are coming to this question from the future, multi-line string interpolation is now a thing.

val when = "now"
println(s"""this is $when a thing.""")
// this is now a thing

Related Query

More Query from same tag