by davidgrenier · 3y ago · 0 comments
Go with goroutines and channels
Clojure with core.async
F# with Hopac
It would be a very interesting project to roll your own in C# using Microsoft Robotics Studio's CCR (Coordination and Concurrency Runtime) (though I speculate those are buffered channels by default).
Concurrency means that you can have multiple tasks running in the same time period, Parallelism means you have multiple tasks running at the same time.
The most obvious demonstration of this is that you can (and many languages do) have single threaded concurrency.
I did some grad course work in parallel programming and there's really no way to not make it "brutal", because to really do it in a way that increases performance you need to really understand some low-level performance issues.
Parallelism is used to solve CPU bound problems. Obvious examples are things like efficient matrix multiplication. However this is what make Parallel programming so hard. There's a lot of nuance working effectively with multiple cores/threads that makes even "embarrassingly parallel" problems sometimes fail to see benefits from naive parallel programming (for example if your parallel solution requires something as little as more frequent visits to l2 cache instead of l1 you can see performance degradation).
So parallelism and concurrency ultimately solve two very different domains of problems.
I agree however they do ultimateively solve two very different domains of problems and there is a lot of confusion going on here.
On a side note: matrix multiplcation is generally not a CPU bound problem, but a memory bound one.
Looking into the future, parallelism is one of the only remaining techniques for scaling classical computing. Processors have stopped getting faster. Instead, they're getting fatter (more cores).
Parallel computing cares about what should be parallel, i.e., actually implementing parallelism. For most programmers, this job can (and probably should) be left to the scheduler, whose job is to translate concurrency into reasonably sane parallelism.
The scheduler comes with overhead, though, that can be avoided with hand-spun parallelism. I like to think about it like manual memory management: for most programs and programmers, using a garbage collector that a memory management expert wrote is easier/better than manually allocating and freeing memory, but there are performance gains to be had if you don't.