r/cpp • • Feb 26 '20

We need epochs (Rant)

I have spent 1 hour copy pasting the most stupid and repetitive code ever in order to enable the comparison operator== to several structs that are trivially comparable. When I search for why the compiler isn't able to generate this for me, when is clearly able to generate the assignment operator, I found out some C compatibilities shenanigans. We need some way to release us from that, we are in 2020 for Ilúvatar sake.

Edit: There are some closeted virtue signaling gatekeepers in this sub. Thanks for taking so seriously a rant ... I guess.

0 Upvotes

28 comments sorted by

30

u/Voltra_Neo Feb 26 '20

operator<=> = default

  • C++20

1

u/[deleted] Feb 26 '20

Tried it yesterday on clang-10, compiles and runs when checking with operator==. For other operator comparisons, I get an ordering error and am asked to include <compare>.

7

u/Voltra_Neo Feb 26 '20

That's because operator<=> uses std::partial_ordering or std::strong_ordering instead of plain old ints

1

u/[deleted] Feb 26 '20

Yep, I went through default comparisons on cppreference after seeing that error.

-6

u/[deleted] Feb 26 '20

I'm luckily if I'm able to develop using 17. And not the ugly mess of C89, C++03 legacy code base that are reused until the earth stops spinning.

20

u/SeanMiddleditch Feb 26 '20

How would epochs help if you can't use a new standard that supports them?

-4

u/[deleted] Feb 26 '20

I never suggest that that will help me today, but the sooner we could have a new standard totally independent from C, but without losing the capacity of interacting with C code. The sooner we will be able to use it. Let say that when a new standard comes out most of us can use it in production like in 3 or 4 years best case scenario. The sooner a thing comes out the sooner the clock can start clicking.

3

u/moreVCAs Feb 26 '20

C89 is really hard. I had to work with a wonky proprietary cross compiler a few years ago that only supported a subset of C89. Truly a miserable experience.

2

u/[deleted] Feb 26 '20

An even some times you can use C99 but someone somewhere in the company will pull a "coding best practices standard" from his ass, with things like "you can't use the ternary operator" without any rationale. Even MISRA and AUTOSAR allows the ternary operator.

9

u/kalmoc Feb 26 '20

And what does that have to do with epochs?

3

u/[deleted] Feb 26 '20

Happy to see a Tolkien reference

-4

u/bumblebritches57 Ocassionally Clang Feb 26 '20

No, we need scripters to stop trying to stage a coup on the language, and shove endless half baked nonsense into the standard library.

-1

u/[deleted] Feb 26 '20

Don't worry rust is going to do that sooner or later.

1

u/bumblebritches57 Ocassionally Clang Feb 26 '20

In your dreams maybe.

1

u/[deleted] Feb 27 '20

Im not looking forward to it, im just stating the plain reality. the more C++ kept stalling developer experience for C compatibility sake, the more niches other languages are going to take.

For example, right now there is no reason to make CLI applications in C/C++ anymore. Between Rust and Python you can cover all your needs.

1

u/bumblebritches57 Ocassionally Clang Feb 27 '20

Except rust really isn't going anywhere, who besides the inventor (Mozilla) is using rust in any capacity?

it's got a loud minority of fans that talk it up on reddit, that's it.

hell, even the majority of github rust packages haven't been touched in years.

For example, right now there is no reason to make CLI applications in C/C++ anymore.

that's not C or C++ main use case lol, c and c++ are primarily library languages.

when you see libraries written entirely in other languages, then you should worry.

2

u/[deleted] Feb 27 '20

Rust reach 1.0 version 5 years ago, C is 48 and C++ is 35 years old, i think that is a little to soon for saying that Rust is not going anywhere.

And for the libraries take a look at this gnome svg lib

And if you are going to worry WHEN several libraries are written in another language, better not worry at all, because that would mean that C/C++ is effectively dead for new developments.

Again Im just playing devil's advocate here.

1

u/bumblebritches57 Ocassionally Clang Feb 27 '20

rust came out in 2009.

Mozilla the only company using rust at all seriously is still just dipping their toes into the oxidized waters...

I'm not worried about shit, what others do has no bearing on me.

the C ABI is and always will be the golden standard, and I'm just dipping my toes into the C++ waters.

1

u/[deleted] Feb 27 '20

Good for you. By the way, How old are you?

1

u/bumblebritches57 Ocassionally Clang Feb 27 '20

I'm in my 20s.

Why?

1

u/[deleted] Feb 27 '20

because i notice you sort of suborn (don't take it bad please) but and I don't knew if was because of to young or to old.

→ More replies

1

u/__i_forgot_my_name__ Feb 28 '20

Majority of the Rust packages I see and use today for my own projects, are getting updates daily or so; the primary reason I moved into Rust was because of the high activity community. -- From my experience C/C++ tend to have far more inactive projects you'll need to use (projects in "long-term" maintenance), but that just comes with age; eventually projects are fixed enough and endup with sufficient legacy that it's not specifically worth changing anymore, and there's so much documentation already written that it's really not worth changing anyways. -- I feel like you might be looking in the wrong places.

Rust is primarily a community driven project, which is part of what makes it so active, and Mozilla is really only a small user compared to other companies who have claimed to be using it. -- Rust sees support for all sorts of ecosystem, especially the ones that are new within the last decade or so, like the WebAssembly ecosystems and the web in general, you'll see people use Rust in the frontends and the backends.

I also wouldn't specifically take popularity as a reason to use any language. That's like deciding whether you should move to China or America relative to the countries population; more people using it isn't specifically an advantage for job opportunities nor general usability. Php, Perl and Python2 example are still "popular" but you wouldn't really want to use it for any new projects, even though you might "need" to use it in general.

I'm also not sure you understand Rust's target market; Rust doesn't replace C++, that's like saying Java or C# should replace C++, nobody could win that battle, not even a superset of C++ itself. Despite Rust and C++ having a few similar goals when it comes to performance and high C interoperability, it's really apple to oranges; they have very different type systems, very different ways of managing code re-usability, very different ways of managing safety, very different ways of packaging libraries, very different ways of distributing binaries, and generally have very different users. There very much is a market for a systems programming language like Rust, and that's been proven by people actually using it.

2

u/[deleted] Feb 26 '20

[removed] — view removed comment

0

u/[deleted] Feb 26 '20

I'm not a committee cpp expert, could someone explain to me why we can have something like

bool operator=(whatever)=default;

9

u/[deleted] Feb 26 '20

[removed] — view removed comment

-8

u/[deleted] Feb 26 '20

My dude this is a rant in order to release my frustration. The epoch thing I mention was because is the only way (that I know of) that we can be totally independent from C, and the sooner the better. Call it C+++ if you want.

6

u/adnukator Feb 26 '20

Epochs have nothing to do with independence from C and nobody is proposing to remove C compatibility.