4 ms·
FTA: "If it was written in C++, it would be threaded code" Uh, why?
by jamieb 14y ago
FTA: "If it was written in C++, it would be threaded code"
Uh, why?
- wmf 14y agoBecause many people find threads easier to understand than callbacks?
- jussij 14y agoBecause that’s one approach to getting the most out of all of those multiple core CPU servers. For Go that came for free because its Communicating Sequential Processes design does that for you.
- abraininavat 14y agoCame for free? Go takes advantage of multiple cores by using threads. CSP doesn't magically multiplex your code onto your cores.
- jussij 14y ago> CSP doesn't magically multiplex your code onto your cores Take a look at this Rob Pike video: http://blog.golang.org/2013/01/concurrency-is-not-parallelism.html http://blog.golang.org/2013/01/concurrency-is-not-parallelis... Now that video might well be crap, I'll be the first to admit I'm not skill enough to know one way or the other. But based on that video, it does appear to me that Go does offer some form of multi-core magic and it does appear to come at a minimal cost.
- abraininavat 14y agoIt's not magic. It's threads. Go multiplexes your goroutines onto N OS threads. There are also abstractions in C/C++ (though of course as libs, not part of the language, like in Go) which hide the usage of threads. But there is no magic. If your code is running in parallel, your code is using OS threads.