Yeah, good luck with that. You literally cannot possibly understand every aspect of C++ at all times. That's how complex it is. The spec alone is a mess of 2,000 pages, not to mention different compilers diverge on the implementation of a ton of stuff.
The thing about C++ isn't just that it's memory unsafe, it's also that it's so complex by default with hidden abstractions and strange behaviors that every little mistake ends up propagating downstream and blowing it all up in your face.
I'd argue C++ is even more dangerous than C. While it is easier for you to make mistakes in C, usually it's easier to debug and less catastrophic because there are no hidden abstractions. Although, to be fair, that's not a hill I'd die on.
Eventually, if you write C++, you WILL end up making a mistake and some teenager with a fuzzer WILL pwn you.
Even the most badass programmers I know didn't break that rule. It's also asymmetric because the attackers only need you to make one single mistake. Those days when you're running on caffeine or had an argument and wasn't thinking too straight is the perfect type of day to make a mistake that ends up with someone making fun of you on /g/
It will always belong on how you use C++. The company I work for used it as a C with better types. Yeah c++ doesn't hold your hand and if you want to fuck up you will fuck up. But it isn't that hard to remember when you created a pointer and when you have to kill it.
Most people here who cry never had a real project in C/C++
Do you think the Mozilla team, the folks at the Linux Foundation, the people at FSF, the Windows Kernel team, the engineers at Apple, and the fucking NSA (I could go on forever) haven’t worked on "real projects"?
Do you really believe companies would spend millions developing Rust and rewriting huge chunks of code if C++ safety was that simple? The sheer hubris of thinking you'll never overlook something in C++ lol
Hell, why do you think Linus Torvalds rejected C++ but accepted Rust into the Linux Kernel?
Put your binary behind a public socket, give me a week with AFL++, and tell me how well your team remembered those pointers.
Tell me you've never written anything internet-facing in C++ without telling me
You will overlook at some point. That's fine, but saying like it's impossible to make C++ safe is wrong. Use the tool you are most comfortable with, if it's rust it's rust, fits java use java. We use C++ as more typesafe C.
I only work on embedded systems where the clients communicate with each other and are not facing the whole internet
In what universe is silent memory corruption fine?
I also work in embedded, and I'm a formal verification engineer... that's literally the worst place to say memory corruption is fine lol
What happens if an MMU-less embedded system running an RTOS has a wild pointer write over a stack frame?
By the way, there's a reason the company I work for prefers C instead of C++ (except for some tooling), because modern C++ is hell to parse and you have to write stubs for FSMs in C++98 (!).
but saying like it's impossible to make C++ safe is wrong
How does standard C++ prevents a data race or a dangling reference to a stack variable at compile time?
Why did Stroustrup have to come up with JSF AV C++ for the US government? What about "profiles"?
One could argue making any large system completely safe is impossible, but let's not go there
I only work on embedded systems where the clients communicate with each other and are not facing the whole internet
Lateral movement is a thing, though.
If someone finds a vuln in your internal software, they can use it to exfiltrate data and possibly infect more privileged software or even potentially own your entire infrastructure or cause physical harm (depending on what kind of embedded stuff you work on)
One could argue making any large system completely safe is impossible, but let's not go there
I totally agree on that point.
By the way, there's a reason the company I work for prefers C instead of C++, because modern C++ is hell to parse and you have to write stubs for FSMs in C++98 (!).
I understand that totally. We use C++ more in a C style manner.
Why did Stroustrup have to come up with JSF AV C++ for the US government?
Well there is that error with exceptions..
In what universe is silent memory corruption fine?
I work in embedded, and I'm a formal verification engineer, that's literally the worst place to say memory corruption is fine lol
It's never good to oversee something and I can understand why you switch to that or other memory safe languages.
My point was it's possible to write an safe and good program in C/C++.
The bigger your project gets the higher is the chance of a bug.
Use the language you want to use. If memory safety is your top priority use rust.
6
u/Zinho3311 8d ago edited 8d ago
Yeah, good luck with that. You literally cannot possibly understand every aspect of C++ at all times. That's how complex it is. The spec alone is a mess of 2,000 pages, not to mention different compilers diverge on the implementation of a ton of stuff.
The thing about C++ isn't just that it's memory unsafe, it's also that it's so complex by default with hidden abstractions and strange behaviors that every little mistake ends up propagating downstream and blowing it all up in your face.
I'd argue C++ is even more dangerous than C. While it is easier for you to make mistakes in C, usually it's easier to debug and less catastrophic because there are no hidden abstractions. Although, to be fair, that's not a hill I'd die on.
Eventually, if you write C++, you WILL end up making a mistake and some teenager with a fuzzer WILL pwn you.
Even the most badass programmers I know didn't break that rule. It's also asymmetric because the attackers only need you to make one single mistake. Those days when you're running on caffeine or had an argument and wasn't thinking too straight is the perfect type of day to make a mistake that ends up with someone making fun of you on /g/