Table of contents
Functional Programming
Functional programming is fascinating, albeit complex and not exactly easy to understand. In FP, programs are built out of pure functions, i.e. functions which have no dependency on anything other than their arguments. Only influence on the outside world is the return value. According to the section in Programming Clojure pure functions and immutable data go hand in hand and are core to the language.
In classic FP, there is a heavy use of recursion and laziness. In Clojure, functions and expressions are not lazy. However, sequences are generally lazy.
Software Transactional Memory
Software transactional memory (STM)[1] is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing. It functions as an alternative to lock-based synchronization.
The key is that STP is optimistic and completes modifications to shared memory without regard for what other threads might be doing (reads and writes are logged). The benefit of this optimistic approach is increased concurrency, since no thread needs to wait for access to a resource, and different threads can safely and simultaneously modify disjoint parts of a data structure that would normally be protected under the same lock.
Clojure specifically uses Multiversion Concurrency Control[2]. Also Clojure transactions are consistent (i.e. ACID).
Sources
- 1. http://en.wikipedia.org/wiki/Softwar...ctional_memory
- 2. http://clojure.org/refs. Also see section 6.2 of Programming Clojure

Comments