Multi-Core And Concurrency - Languages, Libraries And Development Techniques
The CPU architecture landscape has changed, multiple cores is a trend that will change how we have to develop software. I've done multi-threaded development in C, C++ and Java, I've done multi-process development using various IPC mechanisms. Traditional approaches of using threads doesn't seem to make it easy, for the developer, to utilize hardware that supports a high degree of concurrency.
What languages, libraries and development techniques are you aware of that help alleviate the traditional challenges of creating concurrent applications? I'm obviously thinking of issues like deadlocks and race conditions. Design techniques, libraries, tools, etc. are also interesting that help actually take advantage of and ensure that the available resources are being utilized - just writing a safe, robust threaded application doesn't ensure that it's using all the available cores.
What I've seen so far is:
- Erlang: process based, message passing IPC, the 'actor's model of concurrency
- Dramatis: actors model library for Ruby and Python
- Scala: functional programming language for the JVM with some added concurrency support
- Clojure: functional programming language for the JVM with an actors library
- Termite: a port of Erlang's process approach and message passing to Scheme
What else do you know about, what has worked for you and what do you think is interesting to watch?
Answer
I'd suggest two paradigm shifts:
Software Transactional Memory
You may want to take a look at the concept of Software Transactional Memory (STM). The idea is to use optimistic concurrency: any operation that runs in parallel to others try to complete its job in an isolated transaction; if at some point another transaction has been committed that invalidates data on which this transaction is working, the transaction's work is throwed away and the transaction run again.
I think the first widely known implementation of the idea (if not the proof-of-concept and first one) is the one in Haskell : Papers and presentations about transactional memory in Haskell. Many other implementations are listed on Wikipedia's STM article.
Event loops and promises
Another very different way of dealing with concurrency is implemented in the [E programming language](http://en.wikipedia.org/wiki/E_(programming_language%29).
Note that its way of dealing with concurrency, as well as other parts of the language design, is heavily based on the Actor model.
Related Questions
- → Is writing `if (foobar == ("this" || "that"))` to check if foobar is equal to "this" or "that" supported in any major languages?
- → What is a good way of working with variables in 8 bit blocks?
- → What is a better language-introduction preview than "Hello World"?
- → Why does the JNI C API use a pointer-to-pointer instead of straight pointers for JNIEnv?
- → Lex & Yacc: gcc while compiling y.tab.c gives many expected token errors
- → Best framework/language for cross-platform modern GUI designs
- → What languages support covariance on inherited methods' return types?
- → What is Javascript missing?
- → What does "comparison is for a two’s-complement ‘>=’" mean?
- → Multi-Core and Concurrency - Languages, Libraries and Development Techniques
- → Can you monkey patch methods on core types in Python?
- → Would syntax for composition be a useful addition to Java?
- → High-level programming language for music composition