News for hackers. Stuff that matters.
Re:I think C++ is still a desirable coding platform compared... by fwsgonzo on Wednesday November 22, 2023 @08:48AM (#38379058)
I agree. I'm using it both in the game server, the client and for scripting! So far I haven't really had any serious problems that would be related to unsafety. You just have to be disciplined. Source: https://medium.com/@fwsgonzo/using-c-as-a-scripting-language...

I do see that peoples experience with C++ varies wildly, because shops either don't understand why modern C++ exists or they don't care. Either way, predictably, their software suffers and they will routinely run into segfaults. C++ obviously isn't perfect. It's an old language, and while it's trying to reinvent itself it will take some time.

If you ask me though, I don't give a rats ass about the safety things. My $dayjob is a big infrastructure product written in C, which practically never crashes because of memory problems. It just doesn't happen because of extreme discipline. Asserts when entering. Asserts when leaving. Magic values in structs. Sanitizers, clang-tidy, coverage, custom test frameworks, fuzzing. We have it all. And it's C! I understand newbies do better with Rust than C++. It makes a lot of sense. Still, I think that people use Rust more because it's easy to add dependencies, because it has 1 (one) build system, and because of that it's easy to build larger projects because of this. CMake has made good strides recently, but it needs to become the build system for C and C++, and we need global repositories to match Rust. Will that ever happen?

Re:I think C++ is still a desirable coding platform compared... by Yoric on Wednesday November 22, 2023 @09:42AM (#38379835)
That's a lot of boilerplate code, scaffolding and additional instrumentation. In fact, much of my experience with C++ is at Mozilla, which does all of that and more. And still needs a team dedicated to recording and investigating crashes.

That's the reason for which Mozilla (and now some of the developments at Google, Facebook, Microsoft, Amazon) has started moving to Rust a while ago.

Also, I've written it somewhere else, but I'm going to repeat it:

> which practically never crashes because of memory problems

When you have memory issues, crashes are the lucky case. The common case is random memory corruption.

Re:I think C++ is still a desirable coding platform compared... by BanTheBastards on Wednesday November 22, 2023 @08:56AM (#38379161)
Speak for yourself: I'm not returning to the world of "discipline" (aka lost productivity) without a damn good reason to carry on existing codebases. It's just a waste of a good coder and certainly of good time.
Re:I think C++ is still a desirable coding platform compared... by Jyaif on Wednesday November 22, 2023 @09:07AM (#38379312)
In C++ discipline is optional. In Rust it's mandatory.
Re:I think C++ is still a desirable coding platform compared... by steveklabnik on Wednesday November 22, 2023 @12:32PM (#38382219)
I think this is amusing because both directions completely work:

In C++, you can do whatever. Rust forces you do to some things. No discipline required by C++, absolutely required by Rust.

In C++, you can do whatever. Rust forces you to do some things. This means you must have discipline in C++, or you will do bad things. But in Rust, you can do whatever you want, the compiler has your back.

Re:I think C++ is still a desirable coding platform compared... by Jyaif on Wednesday November 29, 2023 @12:12PM (#38462058)
Good point, I was imprecise.

I should have said that no discipline is required in C++ to obtain a binary.

Re:I think C++ is still a desirable coding platform compared... by BanTheBastards on Wednesday November 22, 2023 @10:19AM (#38380396)
I completely disagree; discipline is only optional in C++ if you want to ship broken code. Even the top poster in this thread that actually cops to the productivity overhead of C++ admits (albeit obliquely) they still make memory errors
Re:I think C++ is still a desirable coding platform compared... by timw4mail on Wednesday November 22, 2023 @09:47AM (#38379917)
In C++ crashing with a helpful error is rare. In Rust it's rare not to get a helpful error.
Re:I think C++ is still a desirable coding platform compared... by jackmott42 on Wednesday November 22, 2023 @08:59AM (#38379206)
Even brilliant developers on the Linux kernel teams and Postgres teams make memory mistakes that lead to security problems.

Maybe you are at a higher level than them though.

Re:I think C++ is still a desirable coding platform compared... by fwsgonzo on Wednesday November 22, 2023 @09:05AM (#38379283)
My point is that I am acknowledging that C and C++ needs more discipline. I'm not saying we eliminated this class of bugs!
Re:I think C++ is still a desirable coding platform compared... by mrcsd on Wednesday November 22, 2023 @09:48AM (#38379932)
It sounds like you're working on a mature C++ codebase, so yeah, good reason to stick with that. But I'm curious whether you feel it's worth spending effort on this discipline, outside of working on a particular codebase?

I don't know C++, but being freed from making effort to avoid a class of bugs was easily enough for me to learn Rust instead (not that this was the only reason).

Re:I think C++ is still a desirable coding platform compared... by fwsgonzo on Wednesday November 22, 2023 @09:51AM (#38379964)
I think if I had the opportunity to learn Rust, and some guidance so that I didn't have to do everything the hard way (essentially how I learned C and then C++), then I would!

So far I have used Rust very little, but what I have seen I have liked. I especially liked the much simpler inline assembly in Rust.

Re:I think C++ is still a desirable coding platform compared... by typedef_struct on Wednesday November 22, 2023 @08:50AM (#38379085)
If openssl and skia would switch [to cmake], we'd be on our way.
Re:I think C++ is still a desirable coding platform compared... by fwsgonzo on Wednesday November 22, 2023 @08:52AM (#38379113)
There is this one: https://github.com/janbar/openssl-cmake but I mostly use it to embed OpenSSL.