News for hackers. Stuff that matters.
Re:Why Threads Are a Bad Idea (1995) [pdf] by twtw on Tuesday June 12, 2018 @05:04PM (#17297968)
> Only use threads where true CPU concurrency is needed.

This is the case much more often now than it was in 1995.

Re:Why Threads Are a Bad Idea (1995) [pdf] by ashleyn on Tuesday June 12, 2018 @06:10PM (#17298542)
Not just "more often" but essential. We've been at four hardware threads for a decade now, and we're just entering a new era where increasing the number of CPU cores is becoming a marketing tactic.
Re:Why Threads Are a Bad Idea (1995) [pdf] by nine_k on Tuesday June 12, 2018 @05:40PM (#17298306)
CPU concurrency is not incompatible with events.

Shared mutable state is where the problem lies, but in a lot of cases shared memory can be used to pass it without copying from a "scheduler" thread to worker threads for parallel processing in non-overlapping chunks, and then back for compiling into a whole.

Re:Why Threads Are a Bad Idea (1995) [pdf] by Roboprog on Tuesday June 12, 2018 @05:15PM (#17298077)
Somebody better tell the Node.js cluster guys :-)

They manage without threads pretty well, I think. Shared state is deliberate, outside of individual processes, rather than accidental in-process. As it should be unless you are doing some serious systems level programming.

Re:Why Threads Are a Bad Idea (1995) [pdf] by Roboprog on Wednesday June 13, 2018 @11:44PM (#17309116)
Gotta love the downvotes. So, it’s offensive to suggest that there are alternatives to threading on a post about WHY threading IS a bad idea???

Actor model with messages (events) sent between potentially isolated processes, perhaps?

If you truly need to run a compute intensive task in the background, the effort to [de]serialize a “command object” to and from another process should not be much overhead, vs sharing almost all memory by default.

Once you reach the point where you are starting a thread pool at start up, rather than spawning threads on demand, why not just have a process pool?

Shared memory blocks can also be used to explicitly share data too large to effectively serialize as a message / event.

If you truly have something that pumps huge amounts of data between compute intensive tasks, then threads make sense. Proceed with extreme caution, and try to encapsulate the trick bits.

Re:Why Threads Are a Bad Idea (1995) [pdf] by oldmanhorton on Tuesday June 12, 2018 @05:23PM (#17298160)
To be fair, node.js just merged the --experimental-workers module for actual webworker-style threading.
Re:Why Threads Are a Bad Idea (1995) [pdf] by amelius on Tuesday June 12, 2018 @05:34PM (#17298250)
Does it allow shared (immutable) data structures?

I.e. does it allow passing large parts of data structures without copying?

Re:Why Threads Are a Bad Idea (1995) [pdf] by the-dude on Tuesday June 12, 2018 @05:38PM (#17298295)
I think parent is referring to desktop applications.