3 ms·
Where goroutines have helped me a lot is with networking code. The part of the system I'm writing in Go controls several instances of three different kinds of n
by fauigerzigerk 11y ago
Where goroutines have helped me a lot is with networking code. The part of the system I'm writing in Go controls several instances of three different kinds of networked services, plus one command line tool.
There are hundereds of tasks that request access to these services. The job of my Go code is to schedule, rate limit and coordinate access by these tasks to the network services.
I did parts of it in C++ initially (because other parts of the system are written in C++) using queues and timers (could have done the same in Java) and then I rewrote it in node.js but wasn't happy with the asychronous design or with my productivity.
So I think the reason why goroutines and channels have helped me so much is specific to this kind of project. Go's other language features (or lack thereof) wouldn't have enticed me into taking a closer look. But now that I have taken a closer look, I do like the library and tools a lot as well.
To sum it up, if a program is basically a ton of loops doing blocking reads and writes that depend on each other, then goroutines and channels make the code look very similar to the idea. Mental load drops. Life is easier.