r/cpp 7d ago

cpp2 (cppfront) is over?

I haven't used cpp2 (cppfront) much, but I like the idea of it: consistent syntax, consistency of meta-programming (which is done in C++ too, I believe). Herb Sutter presented cpp2 (cppfront) as an experiment. He did not encourage other people to bet on it, exactly. And there hasn't been much activity since 2022. Is the experiment over?

EDIT: Herb's answer is buried deep in the comment section: https://www.reddit.com/r/cpp/comments/1uxkglj/comment/oy06cxw/

65 Upvotes

112 comments sorted by

View all comments

Show parent comments

9

u/quicknir 7d ago

I can't really imagine any sense in which Rust is a successor to C more so than C++. The feature set in many ways parallels C++, even when the approach is different. Generics, RAII, dynamic polymorphism, built in error handling, containers available in the standard library, a sane string type (i.e. not null terminated), access control, lambdas, etc.

I guess I'm a bit surprised because there's been so much discussion already about Rust as a successor to C++, and while you could argue about exactly how much you like it or exactly how much traction it has, it has most certainly "tangibly materialized".

10

u/13steinj 6d ago

In practice Rust solves C's problems, C++ has them only as a result of backwarda compatibility.

Rust is allowed in the linux kernel, but C++ isnt. Despite the fact that that use compiler extensions to mimic a fraction of C++'s power.

2

u/quicknir 6d ago

Rust also solves a lot of C++'s problems - safety, bad compiler error messages, etc. But regardless of which set of problems it solves, the reality is that Rust as a language is still much more similar to C++ than C, and it's pretty clear that Rust models itself as trying to be an improved C++, even if you don't happen to agree that it succeeded. Zig and Odin model themselves as improvements on C.

6

u/13steinj 6d ago

In practice Rust solves C's problems [safety], C++ has them only as a result of backwards compatibility.

It's a mixed level of fairness to claim that safety is a C++ problem. Quite literally use unique_ptr and call it a day.

4

u/pjmlp 6d ago

If we ignore all the folks that insist in using pointer arithmetic, C strings and C arrays, C style casts, malloc and free, in C++ code, or most C inherited headers for that matter.

It isn't as simple as using unique_ptr and call it a day.

5

u/13steinj 6d ago

I don't follow the pointer arithmetic problem, when using modern tooling (e.g. span, iterators, etc.

Anybody starting greenfield projects has to actively choose to use C warts, and this is for 6-8 years or so now. It is not C++'s problem that users of C++ have refused to update their code. To claim Rust / insert other lang solves it instead is insane, as people still have to change their code.

1

u/pjmlp 5d ago

It solves the problem by not being copy paste compatible with C.

Just look at code samples from companies with seat at the WG21 table, even recent ones.

Some devs don't really want to improve themselves, this is even worse among those that aren't on Reddit, HN or could not care for one second what happens at C++ conferences.

Not being copy paste compatible with C solves a lot of problems.

1

u/13steinj 5d ago

Firstly, I'm fairly sure it's actually not copy-paste compatible. There's some edge cases there. I used to know them, but they were so rare and I never wrote them, so I removed them from my brain.

I never wrote them because I've never had to copy paste C into C++ nor write it from scratch in this way.

If people consider this C++'s problem, I cannot be convinced. To me the only response I can give is "skill issue. Stop copypasting, stop hiring bad devs out of university." Arguably that's its own problem, that as a society we teach computer science but not "how to be an engineer [and write quality software]."

1

u/jwakely libstdc++ tamer, LWG chair 3d ago

We tried saying "skill issue, just don't write bugs" for more than two decades. It didn't work.

1

u/13steinj 3d ago

Not not writing bugs. Writing C-style code in C++.

You can enforce this with decent CI practices and generally static analysis. To the people who refuse to set it up, I've stopped caring.

1

u/jwakely libstdc++ tamer, LWG chair 3d ago

"Just don't write bad/non-idiomatic/un-modern code" is equivalent to "Just don't write bugs".

1

u/13steinj 2d ago

That's a false dichotomy. Yeah, you might write non-idiomatic/un-modern code. You catch it in CI using (sometimes custom) clang-tidy checks.

If your organization can't get developer buy in for this, that is on them, IMO.

→ More replies (0)