I mean, I've only done Ruby and C# in my professional life, but they both do it and I know from school that Java does it and I think python does too? I don't know, those could be outliers and be the only ones who does this.
I don’t think any of the languages you’ve named do this to the same extent as JavaScript. I could be wrong, but if I recall correctly Java and C# will coerce to a string if you’re concatenating, but will still throw an error if you’re passing to a function that expects a string (like this case in JavaScript). I don’t think Python implicitly coerces anywhere (outside of functions like print and explicit string interpolation). I’m not sure about Ruby, but I think it only coerces certain string-like types in certain contexts.
Old JavaScript would coerce everywhere imaginable because it really didn’t want to throw errors.
The languages that maybe do similar with I can think of are Perl and Php.
View all comments
Show parent comment
1
u/theKrissam Mar 21 '24
I mean, I've only done Ruby and C# in my professional life, but they both do it and I know from school that Java does it and I think python does too? I don't know, those could be outliers and be the only ones who does this.
But I don't see how it's errorprone though.