2 ms·
First off there's nothing intuitive about programming, PLs, or PLT. And certainly nothing perfect about anything related to computers at all. "5" + 5 Whic
by agentultra 13y ago
First off there's nothing intuitive about programming, PLs, or PLT. And certainly nothing perfect about anything related to computers at 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.