This. In python everything you'd intuitively expect to work will work for the most part, and things that make no sense result in exceptions. JS, on the other hand..
Why does that not make sense? Adding an object to a string implicitly converts the object to a string and then concatenates the two strings, and the default conversion for object is "[object Object]" if .toString() isn't defined.
Next you're going to tell me that 5 + 1.0 should also error because it implicitly promotes an integer to a double.
Edit: so this comment is dragging out all of the butthurt python fanbois. Here's the deal: your pretty little scripting language was written with auxiliary operating system tasks in mind, and was later adopted by statisticians and mathematicians. Of course it has hard typing and extensive error handling.
But JavaScript was originally integrated into HTML. That's frontend. Frontend needs implicit string conversions, because typing str(some_var) over and over again gets real annoying, real fast. "10" == 10 is a bit more arguable, but I suppose it has its use in validating input. Also, when you have a user on your frontend, the last thing you want is everything to come crashing down because of some formatting error in a string that gets shown to the user maybe once in a blue moon. There's probably some performance reasons for the way things are as well, because V8 compiles hot code into machine code - I imagine it's cheaper to just have a toString() defined to return a constant somewhere instead of checking for nullptr and slinging errors around...
In any case, Lua is, objectively, the best scripting language.
I think js is more scary on where it implicitly changes one thing to the something else. Not that python doesn't have similarly grave issues, but some of the stuff it does by itself become issues that aren't immediately seen and breakes something else later on.
Python is a little more strict on what you can have interact, eg. string + number is a no go, but in JS, the string might be converted to an number and added to the number, if it's possible.
140
u/Darcoxy Aug 26 '20
I'm learning Python after learning C and lemme tell you, some stuff that Python does look so illegal yet they work. I love it!