News for hackers. Stuff that matters.
Re:AI migrated legacy COBOL programs to Java, bugs included by Oxodao on Monday August 03, 2026 @08:10AM (#49154695)
php has a separate `.` operator that concatenate and you get an error if you try to do it with a `+`. That's indeed better but most of the time you concatenate with `sprintf` anyway
Re:AI migrated legacy COBOL programs to Java, bugs included by DarkUranium on Tuesday August 04, 2026 @07:23AM (#49167035)
Yes, and it's a surprising good part about PHP (a language that otherwise has an enormous collection of warts, to put it mildly).

I feel like the more dynamic and/or weakly-typed the language is, the more important it is to have a separate concat operator.

The worst ones being weakly-typed and dynamic. Consider `'5' + '10'` in JavaScript vs `'5' - '10'`. I also very much dislike Python's `+` for concat, but at least it's more strongly typed.

PHP, Lua, and Erlang are three examples of dynamically-typed languages with separate concat operators (`.`, `..`, `++`; respectively), and they all are better for it.

That said, even statically-typed languages benefit greatly from it. Maybe if C++ had a concat operator, it'd never end up abusing `<<` for writing to a stream (yes, there's no opposite for reading, but maybe they wouldn't end up doing that in this case).

For example, D uses `~` in infix for concat. Even UnrealScript, a 1990s game-engine-specific language (which tend to be a mess in general) did this right (it uses `$` or `@` --- with `a @ b` being equivalent to `a $ " " $ b`, IIRC).