News for hackers. Stuff that matters.
Re:C++23: The Next C++ Standard by fsloth on Tuesday July 11, 2023 @02:54PM (#36685621)
The majority of time in professional codebases is not spent on typing but reading and understanding code.

"saves a bunch of time and makes code way more readable"

Not when everybody defines their own operators.

Note - we are discussing operator overloading, not operators as features in syntax. Operators at the syntax level make life a lot easier. But then everybody uses the exactly same operator semantics, not some weird per-project abstraction.

The lines of code you wrote as an example are not saving anyones time, except when writing it if you are a slow typist and lack a proper IDE support for C++. If typing speed is an issue, get a better IDE, don't write terser code.

Re:C++23: The Next C++ Standard by jenadine on Tuesday July 11, 2023 @03:56PM (#36686462)
Hiding the actual logic in extra boilerplate doesn't make it easier to read.

The lines of code in the example save reader's time as they focus attention on the actual business logic.

Yes, this assumes that operator overloading follows some convention, but you need to follow conventions regardless to make readable code.

Re:C++23: The Next C++ Standard by lost_tourist on Tuesday July 11, 2023 @04:31PM (#36686841)
by this reasoning should we get rid of templates/generics as well?
Re:C++23: The Next C++ Standard by enriquto on Tuesday July 11, 2023 @05:07PM (#36687228)
YES
Re:C++23: The Next C++ Standard by woooooo on Tuesday July 11, 2023 @06:49PM (#36688281)
Making things explicit isn't necessarily boilerplate.
Re:C++23: The Next C++ Standard by joshuamorton on Tuesday July 11, 2023 @04:20PM (#36686709)
Code is read more often than written. Writing code that can be understood at a glance (by using common, well understood operators) optimizes for readability.

I think your argument is basically "people should not aggressively violate the implicit bonds of interfaces", which is true. But that goes for all interfaces, not just and not in particular those around operators.

We just have cases where it's common with operators because those are one of the few cases where we have lots of things that meet the interface and interact directly as opposed to hierarchically. The same kind of issue comes up with co/contravariant types and containers sometimes, but that's less often visible to end developers.

Re:C++23: The Next C++ Standard by cogman10 on Tuesday July 11, 2023 @06:46PM (#36688257)
I tend to agree with this. I like operator overloading for mathematical constructs (like complex numbers or even just for conversions of literal types, Imagine, for example, you have a gram type and a second type, if you said 1g / 1s you'd get 1gps, that seems reasonable)

I don't like it in the example given

    for (int i : std::views::iota(0, 6)
               | std::views::filter(even)
               | std::views::transform(square))
What benefit does this have over the Javay/Rusty version that looks like this

    for (int i : std::views::iota(0, 6)
               .filter(even)
               .transform(square))
?

No deducing what `|` means, you are applying the filter then transform function against the view.

Re:C++23: The Next C++ Standard by JonChesterfield on Tuesday July 11, 2023 @08:14PM (#36688867)
People don't use the same operator semantics. Is + commutative? Does it raise exceptions or sometimes return sentinels? What type conversions might == do?
Re:C++23: The Next C++ Standard by SubjectToChange on Wednesday July 12, 2023 @03:27AM (#36691414)
And how exactly do you propose library authors should work with user-defined types? Operator overloading is what allows algorithms to be efficiently generalized across types.