There are many different approaches to STM . This is a very broad topic, such as βtype systemsβ: one approach can easily succeed, while other approaches fail for various reasons.
Clojure STM has several design solutions that make it IMHO more practical and efficient than previous approaches:
- It does not try to protect arbitrary data with STM - you need to use special managed links such as (
ref and the like). This makes it much simpler and more focused than many previous STM approaches (including the Microsoft approach, at least as described in the above article). - It uses multi-version concurrency control with immutable data . This makes the transaction more efficient and practical. In particular, this means that reading without transactions does not require locking, which is a huge gain in performance ....
- This is done in the context of a functional language - in particular, the fact that most of the code in Clojure is a side effect by default greatly simplifies the use of methods such as rollbacks.
As a result of these design decisions, Clojure STM is a completely different beast from previous STM approaches, and I think this is possible thanks to its new design. The video below is a bit outdated, but great if you need an overview of how it works:
http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
source share