←back to thread

Go channels are bad

(www.jtolds.com)
298 points jtolds | 1 comments | | HN request time: 2.055s | source
Show context
Jabbles ◴[] No.11210740[source]
Effective Go has always said:

Do not communicate by sharing memory; instead, share memory by communicating.

This approach can be taken too far. Reference counts may be best done by putting a mutex around an integer variable, for instance.

https://golang.org/doc/effective_go.html#sharing

replies(3): >>11210862 #>>11210978 #>>11210990 #
api ◴[] No.11210978[source]
I thought Go had gc. Why would you ever need reference counts?
replies(2): >>11211015 #>>11211294 #
voidlogic ◴[] No.11211015[source]
Non-memory resources that exist within your application.

Example: Perhaps once no instances of an object are in use, you want to remove that object from persistent storage such as a DB.

replies(1): >>11211115 #
api ◴[] No.11211115[source]
Does Go not have finalizers? These are mostly solved problems since the Smalltalk era. Haven't learned Go yet and from what I read I'd be better off with Rust or something that would stretch my brain more like Haskell. When I read about it I get the sense that we are reinventing stuff from the 90s. But hey, it's hip.
replies(3): >>11211141 #>>11211151 #>>11211331 #
1. catnaroek ◴[] No.11211141[source]
Sometimes you need to guarantee that resources are cleaned up in a timely fashion. Finalizers don't help here.