Misc. Programming

Page last modified 22:19, 6 Sep 2009 by mndoci | Page History

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

 

 

 

Tag page
Page statistics
1329 view(s), 4 edit(s), and 3577 character(s)

Comments

You must login to post a comment.

Attach file

Attachments