14

Many reasonably modern programming languages (Java, Python, C++, Ruby) use + to represent string concatenation. "A" + "B" is the string "AB".

Languages with a more mathematical background tend to use other operators for this (Haskell uses the monoid operator <> or the list-specific operator ++, Julia uses *), and some languages with non-C heritage also seem to have diverged from this trend (Elixir uses <>, Perl uses ., Lua uses ..).

What was the first programming language to use + to represent string concatenation? That is, what is the first programming language where it would be idiomatic for me to take two variables a and b containing strings and write a + b, expecting to get something reasonable out of it? I realize C++ predates (and directly influenced) all of the examples I gave above. Did C++ start this trend, or did it borrow the idea from its own predecessors?

New contributor
Silvio Mayolo is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
15
  • 2
    C++ is almost certainly not where this originated from, because string concatenation using a plus operator comes from STL, not from vanilla C++, and <string> was not even standartized before 1998. – introspec Jul 21 at 18:08
  • 2
    I personally find the + notation overly verbose. I prefer SNOBOL/Spitbol where string concatenation is done by the character (that is, whitespace) which you needed to have anyway to separate symbols ... (i.e., juxtaposition leads to concatenation). Among the many improvements to C++ operator overloading I would like would be not just user-defined operator symbols but being able to define operator" " () (to be distinguished from operator""() _suffix_ ...). – davidbak Jul 21 at 18:18
  • 6
    I think BASIC was pretty early here, though not sure if it is the earliest. Or are you not counting BASIC for some reason? – Brian H Jul 21 at 18:19
  • 3
    @JonCuster - perhaps you don't remember because there was no concatenation operator in SNOBOL/Spitbol - as I mention in my comment above! Concatenation just happened: It was such an important expression in a string manipulation language they implemented it as the default operation requiring minimal syntax! Brilliant! (Also used the same (non-)operator to build patterns, the other most important expression in a string manipulation language ...) – davidbak Jul 21 at 18:23
  • 4
    @davidbak <stroustrup.com/whitespace98.pdf> – user3840170 Jul 21 at 18:31
20

The earliest that was easy to find was ALGOL 68.

After further research, it was unlikely to be any form of BASIC. The original Dartmouth BASIC language was initially released in 1964, but had no string variables. Like ALGOL 68, the fourth version of Dartmouth BASIC was released in 1968, but while it was the first version to have string variables, it did not yet have a string concatenation operator. The eighth version of Dartmouth BASIC released in 1971 was the first to support string concatenation, but the operator was &.

5
  • 4
    A (practical) prerequisite for runtime string concatenation is a heap, so that narrows down the possibilities for contending languages in the 1960s. – another-dave Jul 21 at 22:11
  • 6
    @another-dave: Many Pascal dialects supported concatenation even though string objects were statically sized. A runtime error would typically occur if the destination was too small to hold the result. – supercat Jul 21 at 22:35
  • FYI: Basic-PLUS (1972) used + as the string concatenation operator ('&' was used as a line-continuation token). – RBarryYoung Jul 22 at 15:26
  • 2
    Hmm, actually, BASIC-Plus appeared in 1970, but I cannot confirm if it already had string concatenation by then. "+" was definitely in use by BASIC-Plus by 1972. Algol68 on the other hand did not have a working compiler until 1970, so it's a bit fuzzy... – RBarryYoung Jul 22 at 15:40

Your Answer

Silvio Mayolo is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.