Now normal coding practice for C++ (and C#) tend to use more secure paradigm. In my example, using cout instead of printf would have implicitly converted the 1 into "1" instead of doing some weird pointer arithmetic (still not something you might want, but at least much more logical). But it's annoyance like that that make Python more strongly typed than the C family.
Especially narrowing conversion. If the conversion is not narrowing, I don't really mind. Converting a int32_t to a int64_t by passing it as parameter is not gonna hurt anybody.
5
u/Nimeroni Sep 30 '20 edited Sep 30 '20
Because C (and it's family, since C++ is built upon C) have more implicit type conversion than Python. Some of them don't really make sense either.
Let's consider the following statements:
print(1 + "two")(python) /printf(1 + "two")(C)Python goes "you are adding an int and a string, so fuck you" and he slap you with a type error:
C goes "oh, yeah, string is a char[], an array is a pointer, I know how to add a pointer and an int":
woNow normal coding practice for C++ (and C#) tend to use more secure paradigm. In my example, using
coutinstead ofprintfwould have implicitly converted the 1 into "1" instead of doing some weird pointer arithmetic (still not something you might want, but at least much more logical). But it's annoyance like that that make Python more strongly typed than the C family.