Huh? Why?
More simply, "addition" is generally defined as a commutative operation, which this isn't. When people want a non-commutative operation, they call it "multiplication".
For a more superficial but tangible reason, if you just consider the notation, AB is the concatenation of A and B, which is the notation for a product in math. (Recall putting "A" "B" next to each other in Python literally means concatenation, and it's a product in math.)
1. juxtaposition is shorter than any alternative and hence a natural choice for the most common / only operation on the set in question
2. the operation is roughly analogous to function composition, and when you apply two composed functions it looks like f(g(x)) with f and g juxtaposed (if the functions are among those that have the longest history of being written as prefix operators, e.g. sin, cos, log, you don't even need the paren between the f and the g)
3. juxtaposition is a natural way to express an operation which is just "putting stuff together", such as string concatenation
So while it makes sense to denote string concatenation by juxtaposition in mathematics, I think it's a bit of a leap to go from there to say that A * B is the right notation for a programming language. (Actually using juxtaposition would be fine, but a general-purpose programming language is likely to want to reserve juxtaposition for something else.)
Also if you run with the idea that string concatenation = putting two strings together, well, addition is sort of like putting two numbers together. Rephrasing that in mathematical language: natural numbers can be encoded as elements of the free monoid on one generator, in which case the monoid operation turns out to be addition. I think that might be why the A + B notation is preferred over A * B when we have to choose one or the other.
Concatenation of strings is much closer to the tuple approach. And the argument about the number of elements in the type still holds if you keep the string-length fixed.
Multiplication of numbers is commutative, as is the dot product of vectors. So multiplication is sometimes commutative, sometimes not depending on what is being multiplied and how. So why cannot addition be likewise sometimes commutative and sometimes not?
Yes, that's true. But this seems to me like another argument against classifying concatenation as multiplication because if "A concat B" makes sense, then "B concat A" necessarily makes sense as well (notwithstanding that they produce different results).
Except it makes perfect sense. B concat A gives you B followed by A, as opposed to A followed by B. They produce different results, but they make perfect sense. Nobody claimed multiplicative operations cannot make sense if you swap the operands. The claim was they don't have to.
Like I said, in addition, not only do they make sense, but they give you the same result. Here they clearly don't. Therefore, it makes no sense to suggest concatenation is more similar to addition than multiplication.
To which I reiterate my response: because addition in plain English is frequently (if not always?) commutative, whereas multiplication in plain English is frequently NOT commutative (even though it sometimes can be).
But that is manifestly untrue. Ask a native English speaker what "ABC" plus "DEF" is and they will almost certainly respond "ABCDEF". Ask them what "ABC" times "DEF" is and they will almost certainly respond with something analogous to to WTF?
But regardless: I don't know why you're arguing with me back and forth like this. It's not like I set the convention. I didn't design your favorite programming language. I didn't even claim there are zero reasons to denote concatenation with addition in programming. (!) I was just trying to help you understand something I thought you genuinely had a question about: some reasons in favor of using multiplication that make sense, notwithstanding any reasons arguing for the opposite position. And like I told you in the beginning, this isn't absolute, you can quite literally find counterexamples even in math if you go Googling. But your goal was clearly something else entirely, so don't expect me to have anything else to add (whether commutatively or otherwise).
I am trying to understand if the claim you are defending:
> concatenation is a natural product, not a sum
has any merit. I'm "arguing" to see if you have any rebuttals to my objections to your reasoning before I conclude that no, it doesn't.
Going back over this thread I am puzzled by one thing: that original claim was not yours, it was from /u/naniwaduni. You opened with "string + string". Why are you now so vehemently defending "string * string"?
Oh, and just for the record:
> Make those two words mean something instead of literally giving them strings, and see what they tell you.
Well, yeah, of course. Addition applied to fruit is a different operation than addition applied to strings. So?
https://github.com/JuliaLang/julia/issues/1771
In particular:
https://github.com/JuliaLang/julia/issues/1771#issuecomment-...
Undoubtedly, it is a big surprise for new users (without exposure to free monoids :-)), that * is string concatenation.
By the way, in python juxtaposition ("abc" "def") is also valid.