Clojure 1.5.0 RC 1 released
groups.google.com
groups.google.com
The new agent/thread commands sound very interesting:
clojure.core/set-agent-send-executor!, set-agent-send-off-executor!, and send-via
The concurrency primitives have been Clojure's biggest conceptual breakthrough so far, and if they extend that to the automation of thread pools and executors that would amount to building on top of Clojure's greatest strength.
I am less interested in the threading macros (thrush). I dislike the fact that Clojure can, in a sense, be written forwards or backwards. There is a sense of Perl's "there's more than one way to do it" that I dislike.
If you're referring to the distinction between -> and ->>, it's not about direction preference, but rather that functions that conceptually work on a single subject (e.g., conj, assoc) typically take that subject as its first arg, whereas functions that work on a sequence subject (e.g., map, filter) typically take that subject as its last arg. From that consistency emerges the two different threading macros.
(-> (initial) a b c d e)
and
(e (d (c (b (a (initial))))))
I find -> and ->> useful, but the new threading operators kind of silly; they're very easy to implement in terms of -> and ->>, or in terms of higher-order functions, and don't really cover all the use cases one would want---it offends my sense of aesthetics to have them (in their particular implementation) added to the core ns.
and
(e (d (c (b (a (initial)))))) is like "The Californian bay's city".
These variations are different thematic structures to language.
(-> (california) bay-in city-on) ; "The Californian bay's city"
vs. (city-on (bay-in (california))) ; "The city on the bay in California"
The former ("->") starts with what's fed into the pipeline, the latter starts with what you get out of it. In addition, "->" avoids the nesting of expressions regardless of the number of steps, which might be useful in some cases. But both styles have their place.(baz 33 (bar 12 (foo 33 (+ 1 42))))
Is way harder to read than:
(->> (+ 1 42)
(foo 33)
(bar 12)
(baz 33)) (let [fortythree (+ 1 42)
foo33 (foo 33 fortythree)
bar12 (bar 12 foo33)
baz33 (baz 33 bar12)]
baz33)
I understand the logic behind preferring let and a lot of times it really does make things clearer to have everything named and explicit, but especially in prototype code, I find the need to name things to get in the way. I would prefer not naming things over badly named things, for example, and that's usually how I decide between let and thrush (all things being otherwise equal). a(b(c()))
a().b().c()
the latter form requires less mental overhead so why not favour it whenever possible?Edit: I realize vemv's examples are inconsistent as well
Clojure can in many senses be written forwards or backwards. By defining this short macro somewhere...
(defmacro topdown-tale [& stmts]
`(do ~@(reverse stmts)))
we can write our top-level control statement at the top and the functions it calls underneath, by bracketing with... (topdown-tale
...
)As he says, it's based off of some concepts from Enumerator/Iteratee, which AIUI originated or was explored initially in the Haskell space: http://www.haskell.org/haskellwiki/Enumerator_and_iteratee. I found Hickey's presentation a lot easier to understand.
Does anyone have an opinion on whether Clojure still has a chance to become a major language with widespread adoption?
Making Clojure easier for newcomers would be a boon - I've battled with setup and configuration each time I've tried to use Clojure. Having a simple but powerful REPL environment like IPython would be fantastic.
Download and install leiningen (http://leiningen.org) and then you can start up a repl with 'lein repl'.
I wrote a little web app using clojure and when it came to deployment I was really positively surprised:
1) 'lein ring uberwar'
2) copy resulting war file into your tomcat webapps directory
3) you're done
There's also a heroku plugin if you don't like hosting yourself.
Without leiningen clojure is just unusable though. You have to mess with classpathes and wrapping java command line calls in boilerplate.
I think that it's impossible to predict what will be hot or not in the future. You have a zillion frameworks, plug-ins, and languages competing for mindshare, and I ultimately think that no one of these will be 100% dominant. People who like Lisp are going to love working in Lisp no matter what, and those that don't, wont, and it's that simple. You can't expect people who are most comfortable working in Java to move to a Lisp, and you most certainly can't ask a Lisper to do something that looks at all like Java.
I think one thing that will stunt Clojure, is the death of SICP at MIT and Berkely. SICP makes and excellent case for immutability and functional programming, and that knowledge is now more difficult to find and teach. I think the semi-movement from RoR programmers testing out Clojure wasn't going to last, and if people thought that RoR programmers were really going to move to Clojure and make it popular, with its lack of frameworks and anti-OO philosophy, they weren't thinking about the situation too well.
Regardless, Clojure is the only Lisp that currently has a chance for wider adoption, with Heroku and the JVM.
Also, from what I've seen of Rich Hickey's presentations and speeches he's doing a pretty good job making the case for immutability and functional programming.
I'm going on the assumption that there is some feedback loop going on here, and that without people actually being exposed to Lisp in school, then there is probably going to be less people even aware of Lisp's existence. I wonder how many schools will drop Lisp completely now after MIT and Berkeley dropped it.
Now, if Clojure looked like Python, I bet dollars to donuts it would be the number one language in use already.
Who learn clojure is doing so because it will teach him a new way to think. (Clojure will really change the way you think especially if you come from OOP)
The way in which clojure is build makes very difficult to create a single huge framework and it is not helping. You learn Ruby on Rails to build website, not ruby. (That because a framework, for definition, let you do things in just its way). Clojure do not have frameworks, it has a good number of libraries that you can modulate and use as you wish, there is not just one way to do something (macro...?). (Honestly I believe that it is good, especially if you are the kind of programmer who likes to think).
Then what the 1.5 version is bringing (reducers) are pretty cool IMO, then I see the other macros cond->, cond->>, as->, more like sugar, but I have never used it so I am sure I will be surprised.
Awesome, finally!