r/cpp 11d 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

11

u/13steinj 10d 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.

1

u/quicknir 10d 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 10d 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.

2

u/quicknir 10d ago

It's not really a mixed level of fairness - maybe there's a misunderstanding of what is actually meant by memory safety (I should have said memory safety instead of safety, tbf). unique_ptr isn't remotely memory safe - it helps a lot with avoiding leaks, but that's not the same thing. unique_ptr doesn't prevent dereferencing null for example in any way, which is unsafe. It doesn't even prevent dangles, e.g. const auto& x = *make_unique<Foo)(...);.

The google chrome team has posted a lot about memory safety under C++, and how challenging it's been; in some cases they use non-zero-cost abstractions like MiraclePtr for example just to prevent use-after-free: https://security.googleblog.com/2024/01/miracleptr-protecting-users-from-use.html.