4 ms·
Doesn't go also make it relatively easy to write parallel code?
by ilogik 9y ago
Doesn't go also make it relatively easy to write parallel code?
- ztoben 9y agoI believe you're thinking of concurrency, which go handles pretty well with goroutines.
- icedchai 9y agoGo can use multiple cores. Goroutines will run in parallel (assuming GOMAXPROCS > 1.)
- gameswithgo 9y agoNot especially. It has goroutines, C# has Tasks, C++ has green thread libraries. Added onto this are channels which are basically thread safe queues, other languages have those too. (I am aware that there are differences between what features goroutines and Tasks provides) Go's implementation of these things is nice, neat, and all included out of the box though which is nice. In general you can make parallelism easy, or efficient, rarely both, at least not in a way that can solve problems generally. edit: I should add Go does also come with a data-race detection tool which can be very useful. Not sure any other language includes that out of the box!
- Thaxll 9y agoExcept in other languages it's not part of the core, it's an external library. So on the end it's easy to write "parallel" code.
- gameswithgo 9y agoIn C#, Task is part of the language, thread safe queues are part of the core libs. Still not quite as tightly integrated as Go though.
- burntsushi 9y agoI think Go does make it relatively easy to write parallel code in comparison to most other frequently used languages. > Not sure any other language includes that out of the box! Rust's compiler does it by default, at compile time. ;-) Go's race detector is never wrong, but it may omit things. On the other hand, Rust's compiler is also neither wrong nor does it omit things, except under one circumstance: someone, somewhere, wrote `unsafe` code and committed a bug inside that block. ThreadSanitizer is also a thing: https://clang.llvm.org/docs/ThreadSanitizer.html https://clang.llvm.org/docs/ThreadSanitizer.html