The answer would be a mix of A and B, mostly because there seems to be
an assumption that you have to consider concurrency everywhere in
order to be able to have it at some point later. This is not the case.

You do tend to be very explicit about concurrency and only use the
concurrency primitives (refs, atoms, agents and vars) at a few
selected spots, but most of the time you don't have to think about
concurrency at all, since even the smallest parts of the system is
written in a way that allows for concurrency (by using pure functions
and not using the concurrency primitives).

Clojure is a functional programming language, which among other things
means that computation is in general carried out using referentially
transparent (pure) functions. A pure function always return the same
value for the same input and is free from side-effects. Pure functions
are always thread safe and will never be any problem to concurrency.

In a language like Java, mutation of variables and objects is very
often used for performing computations. But this intervenes
calculations that has nothing to do with each other, since a mutating
step in computation A can affect computation B if they operate on the
same objects. The result is that in Java, you have to think about
concurrency when you perform computations, unlike in Clojure.

(Here, I use the word "compute" to mean something like "produce new
data of interest".)

You tend to write the largest part of a Clojure application as
compositions of pure functions. You only have to introduce reference
primitives when you have a long-running process whose state changes
and evolves over time (for instance a game or a server, or anything
that communicates with the outside world and changes thereafter).
Clojure acknowledges the need for things to be able to change, but
keeps that separate from computation. Most library code I have written
hasn't used the concurrency primitives at all. The state changing part
of an application often resides at a higher level.

// raek

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to