Remix.run Logo
zbentley 4 days ago

I mean, you kinda do. Otherwise you won’t understand why bit-shifting to std::cout prints something, which is pretty much day 1 of C++ hello world introduction (yes, I know there are introductions that don’t use that silly syntax sugar. They’re rare, like it or not.)

Like, sure, you don’t have to understand cout’s implementation of operator <<, but you have to know a) that it’s overloadable in the first place, b) that overloads can be arbitrary functions on arbitrary types (surprising if coming from languages that support more limited operator overloading), and c) probably how to google/go-to-documentation on operators for a type to see what bit-shifting a string into stdio does.

That’s … a lot more to learn than, say, printf.

jcelerier 4 days ago | parent [-]

> I mean, you kinda do. Otherwise you won’t understand why bit-shifting to std::cout prints something,

but it's not bit-shifting, it's "<<", which can do different operations in different contexts.

zbentley 4 days ago | parent [-]

…yes, that is what I said people need to understand in operator-overloading-happy environments.

jcelerier 2 days ago | parent [-]

The problem is having the idea than an operator can only represent one thing while in math there's no such rule - people should start programming without the broken mindset that an operator only means one thing, and then things become much easier. Operators are functions, functions can be overloaded and come with default overloads for specific types: adding a special case makes it more complex.