←back to thread

160 points mpweiher | 1 comments | | HN request time: 0.381s | source
Show context
regularfry ◴[] No.43672109[source]
This was 2016. Is it all still true? I know things will be backwards compatible, but I haven't kept track of what else has made it into the toolbox since then.
replies(5): >>43672204 #>>43672264 #>>43672270 #>>43672320 #>>43672419 #
fpoling ◴[] No.43672419[source]
The only thing that changed was Context and its support in networking and other libraries to do asynchronous cancellation. It made managing network connections with channels somewhat easier.

But in general the conclusion still stands. Channels brings unnecessarily complexity. In practice message passing with one queue per goroutine and support for priority message delivery (which one cannot implement with channels) gives better designs with less issues.

replies(1): >>43672810 #
NBJack ◴[] No.43672810[source]
My hot take on context is that it's secretly an anti-pattern used only because of resistance to thread locals. While I understand the desire to avoid spooky action at a distance, the fact that I have to include it in every function signature I could possibly use it in is just a bit exhausting. Given I could inadvertently spin up a new one at will also makes me a bit uneasy.
replies(1): >>43673105 #
fpoling ◴[] No.43673105[source]
One of the often mentioned advantages of Go thread model is that it does not color functions allowing any code to start a goroutine. But with Context needed for any code that can block that advantage is lost with ctx argument being the color.
replies(2): >>43673322 #>>43673483 #
Mawr ◴[] No.43673322[source]
Function arguments do not color functions. If you'd like to call a function that takes a Context argument without it, just pass in a context.Background(). It's a non-issue.

Full rebuttal by jerf here: https://news.ycombinator.com/item?id=39317648

replies(2): >>43674351 #>>43676774 #
1. int_19h ◴[] No.43676774[source]
By the same token, being async doesn't color a function since you can always blocking-wait on the returned promise. But then the callers of that function can't use it async.

Similarly with Context, if your function calls other functions with Context but always passes in Background(), you deprive your callers of the ability to provide their own Context, which is kinda important. So in practice you still end up adding that argument throughout the entire call hierarchy all the way up to the point where the context is no longer relevant.