STM.NET vs Clojure STM

I am wondering how it is possible that Clojure implemented programmatic transactional memory and did not see any problems with this until Microsoft finished its work for C # and noticed some problems that made it inappropriate to implement the STM described here: http: // www. bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnTransactionalMemory.aspx

Any idea please?

+6
source share
2 answers

Clojure started with STM almost from the very beginning of the language, which influenced the language design and how the language is used to make their STM practical. C # was supposed to start with both the existing language and the existing ways of using it, which creates a more complex problem. The most apparent important difference is that Clojure STM starts with immutable data in the core language , and then builds the concept of ontop identity of this and STM on top of the concept of identities. It is also worth noting that they have many different types of STM and clojure STM is very different.

+5
source

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

+3
source

Source: https://habr.com/ru/post/948003/


All Articles