4 ms·
Aside from technical factors, there are social factors involved. For example, both Python and C++ has operator overloading. But in C++ that's horrible and you r
by boxed 1y ago
Aside from technical factors, there are social factors involved. For example, both Python and C++ has operator overloading. But in C++ that's horrible and you run screaming from it, while in Python land it's perfectly fine. What is the difference? Culture and taste.
- HelloNurse 1y agoIt isn't the same operator overloading. In C++ operator overloading can easily mess with fundamental mechanisms, often intentionally; in Python it is usually no more dangerous than defining regular functions and usually employed purposefully for types that form nice algebraic structures.
- pjmlp 1y agoI hardly see the difference, given the capabilities of operator overloading in Python, class MyNum(int): def __add__ (self, other): return super().__add__(other) * 10 n = MyNum(12) a = 45 print(n + a) # oops
- HelloNurse 1y agoThis type confusion would have been identical with a plain function, __add__ is only syntactic sugar: class MyNum(int): def ten_times_sum (self, other): return (self+other)* 10 n = MyNum(12) a = 45 print(n.ten_times_sum(a)) Compare with, for example, fouling the state of output streams from operator>> in C++.
- pjmlp 1y agoHardly any different, trying to pretend Python is somehow better. Operator overload is indeed syntactic sugar for function calls, regardless of the language. By the way, you can overload >> in Python via rshift(), or __rshift__() methods.
- HelloNurse 1y agoOf course I can overload >> in Python, but I cannot foul up output stream state because it doesn't exist. Formally there is little difference between C++ and Python operator overloading and both languages have good syntax for it, but C++ has many rough edges in the standard library and intrinsic complications that can make operator overloading much more interesting in practice. For instance, overload resolution is rarely trivial.
- boxed 1y agoIt's the exact same thing except in Python the community largely has taste. In C++ `cout >> "foo"` exists in the standard library.
- quotemstr 1y agoI love how among a certain set the word "taste" has become an all-purpose substitute for having an argument or making a case. It basically means "I have more social media follows than you do, so I'm right"
- boxed 1y agoI believe the C++ community as a whole are quite convinced that overloading >> for stdout was a mistake.
- quotemstr 1y ago> Culture and taste. You mean accumulated prejudices, myths, and superstitions that most in any given community (programming language related or not) won't challenge for fear of being cast out of the group for heresy.
- boxed 1y agoErr... no I mean the good taste not to overload >> for console output. There's no fear of being cast out, don't be silly.