this post was submitted on 17 Sep 2024
34 points (94.7% liked)

C++

1720 readers
19 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
34
submitted 2 days ago* (last edited 2 days ago) by cmeerw to c/cpp
all 37 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 21 hours ago (1 children)

babe wake up c++++ just dropped

[–] bitfucker 2 points 21 hours ago

C# is C++ and another ++ on top of the existing ++

[–] kSPvhmTOlwvMd7Y7E 3 points 1 day ago (1 children)

I don't understand why this is called a "subset", while clearly containing new syntax

A subset would be understood by older compilers, this is a superset

[–] Tamo240 4 points 23 hours ago* (last edited 13 hours ago)

The goal of this proposal is to advance a superset of C++ with a rigorously safe subset.

The subset is of the proposed syntax superset. Reason being because the superset also contains explicitly unsafe syntax similar to rust.

[–] [email protected] 2 points 1 day ago* (last edited 1 day ago)

While the summary + interview The Register did was decent, when you read the actual paper, the proposal is way more interesting.

Not a fan of mut instead of just plain mutable, though.

Also I sure hope the compiler messages for this feature won't be like the circle examples in the proposal in the end.

[–] [email protected] 6 points 2 days ago (2 children)

The problem with c++ is that it allows people to do whatever they want. Turns out: people are dumb. Rust solved that problem. Nothing more, nothing less.

[–] [email protected] 6 points 2 days ago

I heavily disagree. C++ has a lot of problems but it's flexibility is not one of them.

Imo the biggest problem with C++ is that there are a dozens ways of doing the same thing. The std lib is not general and fast enough for everyone. Therefore it's not even "standard" .

I have seen many conferences of a proposed "cpp2" like syntax that breaks abi but imo it's the best way forward.

[–] [email protected] -4 points 2 days ago (2 children)

Rust still allows people to do (basically) whatever they want via unsafe blocks.

[–] FizzyOrange 8 points 2 days ago (1 children)

Yeah but I have written a lot of Rust and I have yet to use a single unsafe block.

Saying "but.. unsafe!" is like saying Python isn't memory safe because it has ctypes, or Go isn't memory safe because of its unsafe package.

[–] [email protected] -5 points 2 days ago

See my reply to funtrek's reply.

[–] [email protected] 6 points 2 days ago (1 children)

Sure, but you have to explicitly enable this feature. In c++ you can use the oldest shit from twenty years ago and your compiler happily does its job. All my c++ books are full of "you shouldn’t use xy as it is deemed unsafe now, but of course you still can".

[–] [email protected] -5 points 2 days ago (1 children)

If a "safe C++" proposal truly proposes a safe subset, then yes your C++ code would have to opt-in to doing unsafe things. For the purposes of this discussion of a safe subset ... the point is moot.

[–] FizzyOrange 5 points 2 days ago (1 children)

It's not moot. The Safe C++ is opt-in to safety. It has to be because otherwise it wouldn't be compatible with existing C++.

[–] [email protected] -4 points 2 days ago* (last edited 2 days ago)

That's a laudable difference /s. Using Rust is also an "opt-in" option.

[–] lysdexic 1 points 2 days ago* (last edited 2 days ago) (5 children)

From the article.

Josh Aas, co-founder and executive director of the Internet Security Research Group (ISRG), which oversees a memory safety initiative called Prossimo, last year told The Register that while it's theoretically possible to write memory-safe C++, that's not happening in real-world scenarios because C++ was not designed from the ground up for memory safety.

That baseless claim doesn't pass the smell check. Just because a feature was not rolled out in the mid-90s would that mean that it's not available today? Utter nonsense.

If your paycheck is highly dependent on pushing a specific tool, of course you have a vested interest in diving head-first in a denial pool.

But cargo cult mentality is here to stay.

[–] nous 13 points 2 days ago (1 children)

Just because a feature was not rolled out in the mid-90s would that mean that it’s not available today?

Adding a feature is one thing, C++ has added a lot of memory safety features over the years. The problem with C++ is it still allows a lot of unsafe ways of working with memory that previous projects used and people still use now. Removing support for these features will break existing code and piss a lot of people off in the process. It is not about adding new features, but removing the unsafe existing features that they are talking about here.

[–] sukhmel 14 points 2 days ago (1 children)

I think, the idea was along the lines of "because C++ was not memory-safe, and it has to stay compatible with how it was, there are still a lot of ways to not write memory-safely"

This makes sense, there are memory-safely features available but there are a lot of programmers that will never willingly use that features, because the olden ways are surely better

Other than that, I agree, when you're paid to fix an unfixable problem you will probably claim something like that and advocate for your solution being the only one that solves this

[–] hunger 10 points 2 days ago (1 children)

If you could reliably write memory safe code in C++, why do devs put memory safety issues intontheir code bases then?

Even highly paid (and probably skilled) devs in the IT industry manage to mess that up pretty regularly. Even if it was: devs using memory safe languages make much fewer mistakes wrt. managing memory... so that tooling does seem to help them at least more than the C++ tooling helps the C++ devs.

[–] lysdexic -4 points 2 days ago (1 children)

If you could reliably write memory safe code in C++, why do devs put memory safety issues intontheir code bases then?

That's a question you can ask to the guys promoting the adoption of languages marketed based on memory safety arguments. I mean, even Rust has a fair share of CVEs whose root cause is unsafe memory management.

[–] FizzyOrange 2 points 2 days ago (1 children)

No it doesn't, that's bullshit.

[–] sukhmel 3 points 1 day ago (1 children)
[–] robinm 2 points 14 hours ago

The fact that rustc has bugs (which is what cve-rs exploit) doesn't invalidate that rust the language is memory safe.

[–] [email protected] 5 points 2 days ago* (last edited 2 days ago)

I think your take is a bit extreme.

Currently their statement (regardless of the questionable justification) is largely correct, no major c++ projects have been written in a safe subset and no real work has really started yet. It isn’t practical.

I do agree with you that a safe form of c++, once fully implemented and not frustrating to use, could easily become viable, the feature can be added. But that’s still years away from practical usage in large project, and even when done, many projects will stick to the older forms, making the transition slow and frustrating.

The practical result is that he’s sort of right, if you just add the word “currently” to his statement.

Otoh, I do agree with you that rust cannot be the sole answer to this problem either, it’s almost as impractical to rewrite codebases in rust as an as-yet unfinished safe form of C++. Only time and lots of effort can fix this problem

[–] BB_C 4 points 2 days ago (2 children)

The only (arguably*) baseless claim in that quote is this part:

it’s theoretically possible to write memory-safe C++

Maybe try to write more humbly and less fanatically, since you don't seem to be that knowledgable about anything (experienced in other threads too).

* It's "theoretically possible" to write memory-safe assembly if we bend contextual meanings enough.

[–] lysdexic -1 points 2 days ago* (last edited 2 days ago) (1 children)

The only (arguably*) baseless claim in that quote is this part:

You do understand you're making that claim on the post discussing the proposal of Safe C++ ?

And to underline the absurdity of your claim, would you argue that it's impossible to write a"hello, world" program in C++ that's not memory-safe? From that point onward, what would it take to make it violate any memory constraints? Are those things avoidable? Think about it for a second before saying nonsense about impossibilities.

[–] BB_C 6 points 2 days ago
  • C++ offers no guaranteed memory safety.
  • A fictional safe C++ that would inevitably break backwards compatibility might as well be called Noel++, because it's not the same language anymore.
  • If that proposal ever gets implemented (it won't), neither the promise of guaranteed memory safety will hold up, nor any big C++ project will adopt it. Big projects don't adopt the (rollingly defined) so-called modern C++ already, and that is something that is a part of the language proper, standardized, and available via multiple implementations.

would you argue that it’s impossible to write a"hello, world" program in C++

bent as expected


This proposal is just a part of a damage control campaign. No (supposedly doable) implementation will ever see the light of day. Ping me when this is proven wrong.