I only meant to illustrate that even in C++ where types have a different meaning I will get a warning with a decent compiler.
In either case the expression in both languages garners a silly result. However Scala is happy with the result and reports nothing wrong with it (not even a warning). I was just surprised is all.
"5" + 5
Which is the sillier result: 10, "10", or "55"? All of them are equally valid based on what system of assumptions and implicit evaluation rules you decide are in effect when interpreting this expression. There are some languages that will output 10. Java/Scala will obviously choose the latter result. Neither of them are wrong.What I think is silly is that, to my knowledge, Scala won't warn you that the result of interpreting this expression is ambiguous and their chosen implementation might not be what you had expected.
A decent C++ compiler will warn you (by default) that adding arrays of bytes to integers doesn't make sense and you are probably making a mistake somewhere. A lesser one will let you opt-in to receive warnings. A poor, silly compiler will just compile it without warning and let you figure out its strange result on your own.
The C++ behavior is notably worse, though: "5" + 5 in C++ is undefined behavior, and will give you a pointer to some mystery data.