News for hackers. Stuff that matters.
Re:Why the C++ standard ships every three years by ChrisSD on Saturday July 13, 2019 @04:41PM (#20430026)
C++ classes vs. Rust traits isn't just a matter of syntax differences.

Btw the function syntax is:

    fn foo(x: u16, y: u16) -> u32
If it were more C++ like it'd be:

    u32 foo(u16 x, u16 y)
Which is less keystrokes if anything.
Re:Why the C++ standard ships every three years by kibwen on Saturday July 13, 2019 @06:34PM (#20430561)
Amusingly, C++ also supports Rust-style function headers, and has since C++11 (which is well before Rust was ever on the radar; really both C++ and Rust were inspired by ML here). The following two are identical in C++:

    u32 foo(u16 x, u16 y)
    auto foo(u16 x, u16 y) -> u32
IIRC there are contexts where the former does not work and the latter is required, which I believe means that ML-style function headers are strictly more powerful in C++ than the original C-style function headers.
Re:Why the C++ standard ships every three years by jimmaswell on Saturday July 13, 2019 @04:50PM (#20430062)
Exactly, they do stuff like fn yet make it longer than necessary otherwise.
Re:Why the C++ standard ships every three years by ChrisSD on Saturday July 13, 2019 @04:52PM (#20430083)
I don't think it should be designed to save keystrokes at the cost of readability.
Re:Why the C++ standard ships every three years by jimmaswell on Saturday July 13, 2019 @04:59PM (#20430119)
It already does that elsewhere, yet strange backwards type definitions are much less readable by default to most programmers. It's like making us learn French when we could have learned British English, assuming American English as a starting point.
Re:Why the C++ standard ships every three years by Thorrez on Saturday July 13, 2019 @06:29PM (#20430539)
Plenty of other languages including a large percent of recent languages have the return type on the right.

Haskell, Visual Basic, Scala, F#, Go, (Rust), Kotlin, TypeScript, Swift.

Even c++ allows you to put return types on the right. Why? Because putting the types on the right allows return type deduction. I think it's better to have a single syntax (all types on the right) rather than 2 syntaxes like c++ has.

https://medium.com/@elizarov/types-are-moving-to-the-right-2...

Re:Why the C++ standard ships every three years by ChrisSD on Saturday July 13, 2019 @05:13PM (#20430205)
I think you have to be careful when presuming to speak for "most programmers".
Re:Why the C++ standard ships every three years by jimmaswell on Saturday July 13, 2019 @05:30PM (#20430285)
Here, at least 40% of programminging is done in C style syntax. The rest isn't in any consistent majority style. Most programmers are probably most familiar with C style and almost all are familiar in some form.

https://www.tiobe.com/tiobe-index/

Re:Why the C++ standard ships every three years by a1369209993 on Saturday July 13, 2019 @06:00PM (#20430437)
I don't think anyone's disputing the claim that "strange backwards type definitions are much less [familiar]". We're saying that familiar is not the same thing as readable(-once-you-know-what-it-is), and that you're talking about the former, not the latter.
Re:Why the C++ standard ships every three years by the_why_of_y on Sunday July 14, 2019 @10:56AM (#20433736)
It depends... if your return type is nested inside a class and you're defining a member function, you'll have to write down a qualified return type name before the qualified member function name, whereas if the return type follows the function name, it can be unqualified because at that point the class extends the scope used for name lookup.

http://www.stroustrup.com/C++11FAQ.html#suffix-return

Re:Why the C++ standard ships every three years by vedantroy on Saturday July 13, 2019 @10:51PM (#20431353)
I am not a rust expert, but I assume the recent many programming languages have a keyword for function declaration is so that functions can be first class objects.
Re:Why the C++ standard ships every three years by hellofunk on Saturday July 13, 2019 @04:54PM (#20430093)
This is one of the most trivial points I've ever heard for liking or disliking a programming language.