Live data from Hacker News

Notes on structured concurrency, or: Go statement considered harmful

vorpus.org

1–10 of 234 posts

Re: Notes on structured concurrency, or: Go statement considered harmful

#2
I thought the title was kinda clickbaity, but it turned out to be a great article. Also the comparison to goto really effectively conveyed the point he was trying to make. I have two questions though:

* Does anything else like this currently exist (other than the Trio library he mentions), which shows that it's a superior paradigm in practice?

* What are the cons to this approach? Why not do it?

Re: Notes on structured concurrency, or: Go statement considered harmful

#3
post #2

I thought the title was kinda clickbaity, but it turned out to be a great article. Also the comparison to goto really effectively conveyed the point he was trying to make. I have two questions though: * Does anything else like this currently exist (other than the Trio library he mentions), which shows that it's a superior paradigm in practice? * What are the cons to this approach? Why not do it?

I don't think its a superior paradigm, just a different one.

I only see his nursery as being useful when you really want your async tasks to complete before the function in which they were dispatched returns. That's far from covering every use case of concurrency!

A lot of the value of concurrency is in background operations. These simply can't be tied to the duration of a function call on the dispatch thread. Doing so will literally kill any advantages of concurrency in the first place, might as well just block directly. (This is especially true of apps modelled as an update loop, you definitely don't want to block that loop.)

I can think of very few places where I'd actually want a nursery, and even in those cases I'd rather use the promises or fork&join already available.

Re: Notes on structured concurrency, or: Go statement considered harmful

#5
Didn't expect to say this, but the article is completely right! This is obviously the right way to write concurrent programs. Kudos for writing this.

One question though. The first part of the article says that "onclick" handlers should be replaced with nurseries as well. But I don't see how. Can someone explain?

Re: Notes on structured concurrency, or: Go statement considered harmful

#6
This is usually why I end up using https://godoc.org/golang.org/x/sync/errgroup instead of straight go statements, as it addresses some of the cancellation and error propogation issues. When I think of my use of naked go statements, it's usually for periodic tasks; having something similarly structured for them would be a clear win to me (though potentially the impact is less significant, as it's less painful to write a well formed periodic task using the go statement and context).

Re: Notes on structured concurrency, or: Go statement considered harmful

#7
This is very very long to explain a very simple pair of ideas:

1) You should be able to declare scoped blocks that mandate execution of all tasks started in that block ends when the scope ends.

2) This is fundamentally superior to all other forms of concurrency.

I get it; this is basically what async/await gets you, but conceptually you can spawn parallel tasks inside an awaited block, and know, absolutely that all of those tasks are resolved when the await resolves.

(this is distinct from a normal awaited block which will execute tasks inside it sequentially, awaiting each one in turn).

...seems like an interesting (and novel) idea to me, but I flat our reject (2) as ridiculous.

Parallel programming is hard, but the approach from rust, to give you formal verification, instead of arbitrarily throwing away useful tools seems much more realistic to me.

Re: Notes on structured concurrency, or: Go statement considered harmful

#8
post #2

I thought the title was kinda clickbaity, but it turned out to be a great article. Also the comparison to goto really effectively conveyed the point he was trying to make. I have two questions though: * Does anything else like this currently exist (other than the Trio library he mentions), which shows that it's a superior paradigm in practice? * What are the cons to this approach? Why not do it?

> * Does anything else like this currently exist (other than the Trio library he mentions), which shows that it's a superior paradigm in practice?

Erlang's supervisor behaviours are basically that. They add some more stuff (the actual supervision) but fundamentally every process in a supervision tree will necessarily manage and outlive all its children processes.

Re: Notes on structured concurrency, or: Go statement considered harmful

#10

This is usually why I end up using https://godoc.org/golang.org/x/sync/errgroup instead of straight go statements, as it addresses some of the cancellation and error propogation issues. When I think of my use of naked go statements, it's usually for periodic tasks; having something similarly structured for them would be a clear win to me (though potentially the impact is less significant, as it's less painful to writ…

Thank you! I had no idea about this package! I rolled my own similar thing, but I'd much rather be using something semi-blessed. Looks like I have some refactoring to do, but that's not always a bad thing.
Post reply on HN