News for hackers. Stuff that matters.
Re:Why Threads Are a Bad Idea (1995) [pdf] by girzel on Tuesday June 12, 2018 @05:17PM (#17298098)
Just FMI: the "events" approach that's recommended in the article over threads, that's how Python libraries like tornado and twisted work, right? And to what extent does the new asyncio Python library assume that functionality?
Re:Why Threads Are a Bad Idea (1995) [pdf] by nine_k on Tuesday June 12, 2018 @05:33PM (#17298235)
Events don't share mutable state (at least implicitly), they carry a copy of data. This eliminates a huge class of thread-related errors.

The canonical thing that works this way is Erlang (and its modern cousin, Elixir). See also "actor model" (e.g. Akka). It is approximately how Windows and Mac GUI used to work (back in the day; did not look at these APIs for ~20 years).

Python async is coroutines, a different kind of concurrency. In it, the event loop is hidden, and coroutines just yield control, implicitly or explicitly, to allow other coroutines proceed. In Python, a CPU-bound task can only run on a single thread, due to the Global Interpreter Lock preventing concurrent modification of data. Coroutines are still useful both for IO and as a general way to describe intertwined, mutually dependent computations. (The earliest, limited Python coroutines were generators.)

Re:Why Threads Are a Bad Idea (1995) [pdf] by AnimalMuppet on Tuesday June 12, 2018 @06:55PM (#17298832)
> Events don't share mutable state (at least implicitly), they carry a copy of data. This eliminates a huge class of thread-related errors.

I'm not sure that's true, at least not in my problem space. Copying data leaves you the possibility of operating on stale data, which will result in the computation returning the wrong answer. To avoid that, you have to let the event handler know somehow when the data has changed. How are you going to do that?

Re:Why Threads Are a Bad Idea (1995) [pdf] by luhn on Tuesday June 12, 2018 @05:28PM (#17298192)
Yep. Twisted, Tornado, and asyncio are all built on the concept of event loops.