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.)
I think when mathematicians call an operation denoted by juxtaposition a "product", that's usually because it's denoted by juxtaposition for some independent reason and they're drawing the syntactic analogy with the numerical product, and there isn't any deeper connection with multiplication than that. Independent reasons for using juxtaposition might include:
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.
I think multiplication for string concatenation makes more sense than just "its juxtaposition so we call it multiplication". If you look at type theory, then a tuple of type (A, B) is called the product type of A and B. This is because there are #A times #B elements in the new type. A Sum type, in type theory is a tagged union. It is an element of Either A or B. (Like a C union with an extra tag saying which type it contains). This is a sum because it contains #A plus #B elements.
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.
> "addition" is generally defined as a commutative operation, which this isn't.
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?
I'm not saying it can't (you'll find occasional counterexamples if you Google), I'm just saying that's the general convention. I don't know why the math community chose this convention, but I know it makes sense to me in English: remember, multiplication is repeated addition. The multiplier doesn't serve the same purpose as the multiplicand; their meanings are fundamentally unrelated. Think of an example. If you have "two rectangles", it's pretty easy to understand what that means, but "rectangle twos" doesn't make any sense (or at least doesn't mean the same thing...).
> The multiplier doesn't serve the same purpose as the multiplicand
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).
> because if "A concat B" makes sense, then "B concat A" necessarily makes sense as well
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.
You are just reiterating the fact that concatenation is not commutative, to which I will reiterate my earlier response: If multiplication can be sometimes commutative and sometimes non-commutative (and it can, and it is) then why cannot addition be sometimes commutative and sometimes non-commutative?
> If multiplication can be sometimes commutative and sometimes non-commutative (and it can, and it is) then why cannot addition be sometimes commutative and sometimes non-commutative?
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?
Make those two words mean something instead of literally giving them strings, and see what they tell you. Ask them if two apples and an orange are the same thing as two oranges and an apple. Put literally any objects and ask them if the sums is the same. I guarantee you far greater than 50% of the things you come up with will result in "same" as the answer.
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 don't know why you're arguing with me back and forth like this.
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?
Huh, neat!. Especially since alternation is commutative. So this is a ring-like structure! We have 'identity' if you allow a pattern that matches nothing. No inverse elements though. Not sure what the name of this ring-like thing is. But pretty certain it is named.
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.)