Welcome to another issue of Clojure Weekly, my small routine blog contribution to the Clojure sphere! These are just a few links, normally 4/5 urls, pointing at articles, documentation, screencasts, podcasts or anything else that attracts my attention. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!
Dissecting Clojure Reducers This talk I gave at Strangeloop 2013 is finally up on InfoQ. I’m still convinced live coding sessions are possible (and will take again the risk in the future if necessary), but this is an example of screwing up and being unable to recover :( The entire working REPL session is published here https://github.com/reborg/talk-strangeloop2013/blob/master/src/strloop2013/core.clj if you want to see how it was expected to finish!
Cognicast :: Podcast I’ve managed to listen to only half of it, but it’s already dense enough to deserve attention. React maintains a virtual DOM representation. Components change the DOM without direct manipulation. Changes are propagated down to the virtual DOM and when it’s time to synch a diff is calculated and the real DOM is updated. OM implements a similar mechanism but since it is using the ClojureScript immutable data structures, it can check equality on identity of objects instead of values, with immediate speedup as a result.
clojure.core - Clojure v1.6 API documentation mapv has the same semantic of map but it returns a vector instead of a seq. It resolves to into for all cases where the inputs are more than one. But possibly the most common case is mapv over a single collection. In this case instead of plain into  an optimised version makes use of transients. Click on “source” to see it in core.clj. Basically: reduce over coll starting from a transient seed, updating in place the results with the transformation and go back to persistent data structures at the end. The creation of the final vector happens outside a persistent data structure, when you can safely assume it is safe to mutate. This is a lesson from std-lib: idiomatic clojure often paysoff in several ways.
weavejester/lein-generate This is brilliant. I’m constantly repeating action like: create a namespace/test pair files from existent ones, change ns names to the new one, require the ns from the test blah blah. If you TDD you know what I mean :) But the plugin offers extendibility as a feature. I’m pretty sure I’ll come up with other repetitive project actions that can be incorporated.
ClojureDocs - clojure.core/dorun doall, doseq and dorun all provide a way to realise lazy sequences, but there are quite important differences. If the only goal is to realise the sequence for side effects, dorun is the preferred, because it does not retain the collection in memory. For some additional degree of sophistication, doseq also offers bindings and destructuring like for and still not return (hence retain) the collection in memory. doall should be used only when the collection should fully realise before leaving some “connection” context, because the element in it are dependent on that. doall often happens on result sets from 3rd party services that need to release the connection before being used.
ClojureDocs - clojure.core/format Format is quite powerful printing function. You can use it with positional args with %s, but I was unaware of other interesting features like padding capabilities. This is one of those things that when you don’t know you end up rolling your own string padding feature (and that can be a 2 hours Yak shaving task).3 days ago