В языке Go есть слоган "Do not communicate by sharing memory; instead, share memory by communicating". Если по-простому, то это означает, что лучше использовать го-каналы, чем прямое изменение переменных (и защищать их мьютексами).



Так вот, было исследование, которое показало, что с точки зрения количества ошибок - это один хер. Т.е. передача сообщений через каналы более наглядна, но при этом всё равно надо знать, что делаешь.



Цитата:



Shared memory vs. message passing. Our study found

that message passing does not necessarily make multithreaded programs less error-prone than shared memory.

In fact, message passing is the main cause of blocking bugs.

To make it worse, when combined with traditional synchronization primitives or with other new language features

and libraries, message passing can cause blocking bugs that

are very hard to detect.

...

We believe that message

passing offers a clean form of inter-thread communication

and can be useful in passing data and signals. But they are

only useful if used correctly, which requires programmers

to not only understand message passing mechanisms well

but also other synchronization mechanisms of Go.