Crystal uses green threads, called fibers, to achieve concurrency. Fibers communicate with each other using channels, as in Go or Clojure, without having to turn to shared memory or locks.
What about Nim?
Nim uses async await to achieve concurrency. Like C#, Python, Hack, Dart, Kotlin, JavaScript and (soon) Rust (in fact, the Rust implementation is worthy of mention as it originally intended to be implemented via macros, it seems they gave up on that for now though. Nim's implementation is still 100% macro-based, and I must say that makes me proud).
I think what you really mean to ask about though is parallelism. Nim has spawn for that, and you can also use channels if you wish.
Thanks for the answers, dom96 and r3d9u11.
So, does that mean that Nim has green threads like https://github.com/python-greenlet?
Or does this answer about Golang (https://softwareengineering.stackexchange.com/questions/222642/are-go-langs-goroutine-pools-just-green-threads#222694) apply equally to Nim language too?
I think that there should be a documentation about Nim's concurrency as comprehensive as the link about Golang above.
Specifically, how does Nim do each of the 3 in this link: https://softwareengineering.stackexchange.com/revisions/254141/2 ?
@Jayadevan, actually there no fundamental difference in definitions of coroutines and fibers in mentioned link.
So if you mean primitive which has its own stack (Windows developers call it fibers , everybody else call it coroutines), then you are looking for https://github.com/nim-lang/Nim/blob/devel/lib/pure/coro.nim. But i need to note this is not working on MacOS properly.
If you mean primitive which don't have its own stack, but using closure iterators to switch coroutines, then you are looking for https://github.com/nim-lang/Nim/blob/devel/lib/pure/asyncdispatch.nim.
@Jayadevan Like @dom96 said, your question about locks and shared memory only makes sense if you are talking about multithreading.
Concurrency can be done with a single thread, you don't need locks and won't have shared memory issue because there is nothing to share memory with.
Locks and shared memory issues only appear when you need to sync multiple threads.
@Jayadevan Here is another one (older) theme for Concurrency (Async IO operations): https://forum.nim-lang.org/t/3640#22691 (with a short clarifications about parallelism and concyrrency). And here is theme with a little experiment of Async IO: https://forum.nim-lang.org/t/3634#22648.
Parallelism: https://nim-lang.org/docs/manual.html#parallel-spawn-spawn-statement https://nim-lang.org/docs/manual.html#parallel-spawn-parallel-statement https://rosettacode.org/wiki/Concurrent_computing#Nim https://rosettacode.org/wiki/Synchronous_concurrency#Nim
May be it will be useful.
Thanks cheatfate, mratsim, r3d9u11. These answers gave me lot of knowledge.
In Wikipedia there is: CSP was highly influential in the design of the occam programming language, and also influenced the design of programming languages such as Limbo, RaftLib, Go, Crystal, and Clojure's core.async.
Nim too can be added to this list of languages, it seems. What is the opinion of experts?