STM.NET versus Clojure STM
Asked Answered
A

2

6

I'm wondering how is that possible that Clojure has implemented Software Transactional Memory and doesn't see any problem with that while Microsoft didn't finish its work for C# and noticed some problems which make it unpractical to implement STM described here: http://www.bluebytesoftware.com/blog/2010/01/03/ABriefRetrospectiveOnTransactionalMemory.aspx

Any idea please?

Aylmer answered 24/6, 2013 at 16:27 Comment(0)
T
5

Clojure started on STM from nearly the beginning of the language which influenced the language design and how the language is used so as to make their STM practical. C# had to start with both an existing language and existing ways of using it which makes for a more difficult problem. The most seemingly important distinction is Clojure's STM starts with immutable data at the core of the language and then builds the concept of identity ontop of that and STM on top of the concept of identities. It's also worth noting that their are many different kinds of STM and clojure's STM is very different.

Teleutospore answered 24/6, 2013 at 17:7 Comment(0)
G
3

The there are many different approaches to STM. It's a very broad topic like "type systems": one approach can easily succeed while other approaches fail for various different reasons.

Clojure's STM has a few design decisions that make it IMHO more practical and effective than previous approaches:

  • It doesn't try to protect arbitrary data with STM - you have to use special managed references like (ref and similar). This makes it a much simpler and more focused design than many earlier STM approaches (this includes Microsoft's approach, at least as described in the above-linked article)
  • It uses multi-version concurrency control with immutable data. This makes transaction handling much more effective and practical. In particular, it means that non-transactional reads don't require any locking, which is a huge performance win....
  • It's done in the context of a functional language - in particular, the fact that most code in Clojure is side-effect free by default makes it much easier to apply such techniques like transaction retries.

As a result of these design decisions, Clojure's STM is a very different beast from previous STM approaches, and I think succeeds because of its novel design. The video below is a bit old but excellent if you want an overview of how it works:

http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey

Guile answered 26/6, 2013 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.