Live data from Hacker News

Why Threads Are a Bad Idea (1995) [pdf]

cc.gatech.edu

21–30 of 103 posts

Re: Why Threads Are a Bad Idea (1995) [pdf]

#21
post #6
post #2

> Only use threads where true CPU concurrency is needed. This is the case much more often now than it was in 1995.

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.

I think parent is referring to desktop applications.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#22
post #12
post #7

Earlier quoted context omitted.

The author is John Osterhout, a CS professor. He was working at Sunlabs at the time. It's not like some unknown lone voice from the bowels of Sun was 'trying to warn us'. Warn us about what, anyway?

There was a hype wave about multithreading (hey BeOS) that started around 1995.

[deleted]

Re: Why Threads Are a Bad Idea (1995) [pdf]

#23
post #2

> Only use threads where true CPU concurrency is needed. This is the case much more often now than it was in 1995.

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]

#24
Oh gee I guess I'm a wizard.

Lots of systems/embedded programmers roll their eyes at this kind of talk. Threads aren't really that hard.

Event queues do have benefits in certain situations. They pair nicely with state machines. You can easily end up in callback hell though, and it is often difficult to integrate some long-running, atomic tasks into your event loop. You end up doing things like having a thread pool, at which point you have to wonder why you stopped using threads in the first place. Oftentimes a threaded approach is a cleaner approach. Just get the locking granularity right - it's not that difficult.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#26
A serious practical problem with threads mirrors the same problem with C++, which is that many programmers reach for it first when they should be reaching for it last. Both of these technologies are like swallowing glass, and the wise programmer will avoid them if at all possible.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#27

Oh gee I guess I'm a wizard. Lots of systems/embedded programmers roll their eyes at this kind of talk. Threads aren't really that hard. Event queues do have benefits in certain situations. They pair nicely with state machines. You can easily end up in callback hell though, and it is often difficult to integrate some long-running, atomic tasks into your event loop. You end up doing things like having a thread pool, a…

Structured threads aren't that hard (e.g. task-based systems, thread pools).

Unmaintanable raw-pthread messes are a nightmare sequel from the director of Endless GOTOs.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#28
post #12
post #7

Earlier quoted context omitted.

The author is John Osterhout, a CS professor. He was working at Sunlabs at the time. It's not like some unknown lone voice from the bowels of Sun was 'trying to warn us'. Warn us about what, anyway?

There was a hype wave about multithreading (hey BeOS) that started around 1995.

BeOS was pretty good, and now that i'm wiser in the tooth, they were basically implementing the Actor model, except since it was in C++, it was really hard to guarantee that the programmers wouldn't do stupid things with shared state.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#29

I have seen that argument in the past but somehow still can't see how event-based approach saves us from the headaches of concurrency. If you need to deal with parallel processing (which is relatively often in the real world) you WILL have to face the problems of consistency, visibility and program order. Many languages don't even require programmers to have much exposure to threading mechanics. It's an OS responsibi…

1995 was a different era.

Re: Why Threads Are a Bad Idea (1995) [pdf]

#30

Oh gee I guess I'm a wizard. Lots of systems/embedded programmers roll their eyes at this kind of talk. Threads aren't really that hard. Event queues do have benefits in certain situations. They pair nicely with state machines. You can easily end up in callback hell though, and it is often difficult to integrate some long-running, atomic tasks into your event loop. You end up doing things like having a thread pool, a…

A lot of work in programming languages over the past decade has been devoted to providing a safety net and guard rails for avoiding the pitfalls of thread-based concurrency. See in particular Rust and Go. It's still quite possible to corrupt data and get deadlocks, but our languages have come a long way to making it harder.

But the point of this article is to say if we ditch the notion of threads entirely and go with this other thing, we won't need safety nets anymore because it will be impossible to deadlock and corrupt data (as opposed to less likely).

Post reply on HN