News for hackers. Stuff that matters.
Re:Orb is a free and open source web desktop by kreetx on Monday August 07, 2023 @06:14AM (#37032506)
I hear PHP is a pretty good language nowdays. Now, if we could just optionally drop the $ sign from the beginning of every variable and use them only for string templating ;).
Re:Orb is a free and open source web desktop by psychoslave on Monday August 07, 2023 @07:18AM (#37032955)
What is so special about string templates that they should be have a different naming scheme? And $ really won't ease your life to search with regexp.

Would it only depends on my own preferences, I would use only letters and dash for any identifier in code bases I work with.

Re:Orb is a free and open source web desktop by anamexis on Monday August 07, 2023 @09:15AM (#37034017)
> What is so special about string templates that they should be have a different naming scheme?

The fact that you have to distinguish between literal strings and interpolated values

Re:Orb is a free and open source web desktop by jdiff on Monday August 07, 2023 @09:32AM (#37034224)
Maybe string interpolation is just a bad idea. Let strings be strings, use string formatting functions if you want to shove data in them.
Re:Orb is a free and open source web desktop by anamexis on Monday August 07, 2023 @09:37AM (#37034274)
Or 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.

Re:Orb is a free and open source web desktop by jdiff on Monday August 07, 2023 @10:42AM (#37035120)
They 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.
Re:Orb is a free and open source web desktop by claytongulick on Monday August 07, 2023 @11:04AM (#37035461)
Maybe take a look at lit-html, postgresjs and some others to get a sense of what's possible with good string templating.
Re:Orb is a free and open source web desktop by jdiff on Monday August 07, 2023 @04:00PM (#37040152)
Those 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.