3 ms·
Maybe string interpolation is just a bad idea. Let strings be strings, use string formatting functions if you want to shove data in them.
by jdiff 3y ago
Maybe string interpolation is just a bad idea. Let strings be strings, use string formatting functions if you want to shove data in them.
- anamexis 3y agoOr maybe they're a very nice convenience, which is why a lot of modern languages are implementing them. String formatting functions use special strings themselves.
- jdiff 3y agoThey do, but very well-defined ones, little placeholders that just concern themselves with formatting. You include the whole variable name and that makes it brittle, now random bits of string data have to be kept in sync with actual code, and makes it a lot more unwieldy to format in a way that isn't the default representation.
- claytongulick 3y agoMaybe take a look at lit-html, postgresjs and some others to get a sense of what's possible with good string templating.
- jdiff 3y agoThose do look quite nice, fairly far away from the nightmares I've dealt with before. They also seem to avoid the problem of just about summoning a whole separate archaic syntax just for jamming variables into a string.