by ilyt · 3y ago · 0 comments
Frankly those who do would try to avoid it anyway unless it is truly the best/only solution to the problem.
The best way to not have concurrency bugs is to have as little of it as possible. If I have a choice of making single job faster vs just running 64 jobs in parallel on CPU I'd pick the second every time I can because code will be simpler and less buggy every single time.
I maybe misunderstanding what you're trying to say, don't you mean you'd pick the first one every time? Make the single job faster instead of introducing concurrency with 64 parallel jobs?
I believe this also happens because often the most accessible/obvious form of concurrency is the super problematic "shared data by default" kind (C/C++/Java "Threads"), which is basically ASKING for trouble.
Also programming education sometimes even reinforces this in a very harmful way from what I've seen. Telling a student about mutexes/semaphores/atomicity is actively harmful IMO if it is not accompanied by strong discouragement and actual practice in finding subtle race conditions.
In C++ the patterns I don't see bugs in is thread pools for processing large batches of heterogeneous data, and fine grained parallelism for stuff like vector and matrix operations. But in the latter case it is all library driven, and in the former, it is a really simple pattern.
I dunno, I reinvented message-passing concurrency with multiple processes before I knew the terminology or had any formal programming training. It came completely naturally and it was nearly a decade before I understood why people thought concurrency was difficult to get right.