1068
C++ (lemmy.zip)
you are viewing a single comment's thread
view the rest of the comments
[-] xmunk@sh.itjust.works 80 points 5 months ago

This graph cuts off early. Once you learn that pointers are a trap for noobs that you should avoid outside really specific circumstances the line crosses zero and goes back into normal land.

[-] 5C5C5C@programming.dev 43 points 5 months ago

Your graph also cuts out early. Eventually you want to get performance gains with multi-threading and concurrency, and then the line drops all the way into hell.

[-] xmunk@sh.itjust.works 17 points 5 months ago

Good Afternoon Sir, have you heard about our lord and savior pthreads?

[-] 5C5C5C@programming.dev 27 points 5 months ago* (last edited 5 months ago)

I'm not saying you can't do multi-threading or concurrency in C++. The problem is that it's far too easy to get data races or deadlocks by making subtle syntactical mistakes that the compiler doesn't catch. pthreads does nothing to help with that.

If you don't need to share any data across threads then sure, everything is easy, but I've never seen such a simple use case in my entire professional career.

All these people talking about "C++ is easy, just don't use pointers!" must be writing the easiest applications of all time and also producing code that's so inefficient they'd probably get performance gains by switching to Python.

[-] deadcream@sopuli.xyz 7 points 5 months ago

That's the problem of most general-use languages out there, including "safe" ones like Java or Go. They all require manual synchronization for shared mutable state.

[-] 5C5C5C@programming.dev 20 points 5 months ago* (last edited 5 months ago)

There's a difference between "You have to decide when to synchronize your state" and "If you make any very small mistake that appears to be perfectly fine in the absence of extremely rigorous scrutiny then this code block will cause a crash or some other incomprehensible undefined behavior 1/10000 times that it gets run, leaving you with no indication of what went wrong or where the problem is."

[-] uis@lemm.ee 4 points 5 months ago

that's so inefficient they'd probably get performance gains by switching to Python.

Damn, this goes hard for no reason.

[-] uis@lemm.ee 1 points 5 months ago

Well, threadsanitizer catches them in runtime. Not sure about GCC static analyser and other SA tools.

[-] 5C5C5C@programming.dev 3 points 5 months ago* (last edited 5 months ago)

I use thread sanitizer and address sanitizer in my CI, and they have certainly helped in some cases, but they don't catch everything. In fact it's the cases that they miss which are by far the most subtle instances of undefined behavior of all.

They also slow down execution so severely that I can't use them when trying to recreate issues that occur in production.

[-] uis@lemm.ee 1 points 5 months ago

They caught lock inversion, that helped to fix obscure hangs, that I couldn't reproduce on my machine, but were constantly happening on machine with more cores.

load more comments (6 replies)
load more comments (6 replies)
load more comments (37 replies)
this post was submitted on 08 Jun 2024
1068 points (98.5% liked)

Programmer Humor

19564 readers
1042 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS