3 ms·
This isn't remotely true. CSP via goroutines and channels is idiomatic Go, but it's not the only option. Go offers mutexes and other concurrency primitives whi
by vox_mollis 11y ago
This isn't remotely true.
CSP via goroutines and channels is idiomatic Go, but it's not the only option. Go offers mutexes and other concurrency primitives which, along with goroutines as lightweight thread analogues, allow what you're looking for.
- nickbauman 11y ago.. mutexes limit you to the locking paradigm. You know there's more/better out there, right? If you want an actor / agent model you still must do this with mutexes channels and goroutines, resulting in some pretty fugly code, more so than normal go code.
- TheDong 11y agoThe real problem here is that Go does not allow a user to create their own powerful concurrency primitives. Locks exist, but you can't create a synchronized data structure. You can't create your own channel type because that's a generic thing which is reserved for the language authors, not the language users. The whole point of modern programming is to create useful abstractions that allow a programmer to get things done without having to worry as much, and concurrency-related abstractions like parallel map-reduce and actors are powerful, but you have zero chance of making an abstraction for that in Go. In Go it's basically CSP or bust; saying "you can use locks" is not an answer; locks are not a way to handle concurrency, they're a primitive for shooting yourself in the foot if you're unfortunate to be in a language where you can't abstract them away suitably.
- nickbauman 11y agoI wish I could upvote this +1000
- fixermark 11y agoI'm not sure what stops someone from creating their own channel types. type MyChannelType chan MyStruct ?
- deleted 11y ago[deleted]