this post was submitted on 05 Apr 2025
160 points (95.5% liked)

Programmer Humor

35007 readers
201 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 1 week ago (9 children)

Why should no one be using c++?

[–] [email protected] 3 points 1 week ago (8 children)

It's memory unsafe and it's syntax is indistinguishable from the runes which summon cthulu.

[–] [email protected] 0 points 1 week ago (5 children)

Memory unsafe C++ is a choice. With modern C++ you have no excuse for accessing raw pointers or arrays without range checking if memory safety is a priority.

[–] [email protected] 3 points 1 week ago (1 children)

Yeah, just don't make any mistakes and you'll be fine. Come on guys, how hard can it be?

[–] [email protected] 1 points 1 week ago (1 children)

As I said: There are tools in place in modern C++ that are designed to catch the errors you make. If you are using a raw pointer when you could have used a reference, or accessing an array without range checking, those are choices you've made. They may be valid choices in your use-case, but don't go complaining that the language is "unsafe" when it gives you the option to code with guard rails and you choose to forgo them.

[–] [email protected] 1 points 1 week ago (1 children)

I'm a full time C++ developer, mostly doing high performance data processing and some visualization and TUI tools, and as someone loving C++, it's not as simple as you frame it. In sufficiently complex code you still have to deal with these problems. Rust has some good mechanisms in place to avoid these and there are things on the way for c++26 though.

[–] [email protected] 1 points 1 week ago (1 children)

I don't mean to say that C++ is in any way without faults. If performance is crucial, that can definitely be a reason to forgo some of the guard-rails, and then you're on your own.

I guess my issue with the "C++ is unsafe"-trope, is that it usually (in my experience) comes from people not having heard of all the guard-rails in the first place, or refusing to use them when appropriate. They write C++ as if they were writing C, and then complain that the language is unsafe when they've made a mistake that is easily avoided using stl-containers.

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

Yes I agree on that. A lot of people write "C with classes" and then complain...

load more comments (3 replies)
load more comments (5 replies)
load more comments (5 replies)