May 14, 2013

Clojure Weekly, May 14th, 2013

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!

Prismatic’s “Graph” at Strange Loop — Prismatic Blog The team at Prismatic is putting a lot of effort in open sourcing their common solution to recurring problems (aka patterns). Graph is part of the Prismatic tool-belt. Basically, it is a way to express a functional composition in terms of a graph based data structure. Instead of a function with a lot of outgoing dependencies to lower level abstraction (and those functions may also be calling into each other) Graph allows to declare what output of which function should be the input into another function. I can see some relevant cases where this can be useful, for example composing chains of responsibilities that otherwise would result in big monster let-blocks at the beginning of a function. At the same time I fail to see how the same problem could not be solved by a better composition and abstraction of functions. I have the impression that if a function is calling into many other functions I might be missing a layer of abstraction and that would be my first attempt at refactoring instead of using graph.

michalmarczyk/flexvec · GitHub Here’s an example of how an interesting and efficient algorithm that improves the current 32-way branching tree used in Clojure vectors can make it as a contrib and maybe to core one day. Relaxed radix balanced trees (hence “flex” because the constrain about the branching is relaxed) are an alternative implementation for balanced trees that allows more efficient concatenation in log(n). The pay a small performance price just after the first concatenation for simple addition operation, but if the vector is never concatenated you get exactly the same B-Tree behaviour of the current Clojure implementation. It was discussed initially in clojure-ML http://tinyurl.com/cs6tuyl and quickly after in clojure-dev http://tinyurl.com/bvby85s and finally ended up in contrib. This data structure can be useful in all cases where concatenation of immutable vectors is used heavily: fork-join kind of operations or simple map-reducing operations producing a vector instead of a scalar.

Dashboard [Hudson] All of Clojure and Clojure contributions are continuously integrated in a Jenkins instance running at the link above. It is kind of interesting to see when it was last built and when it was last failing. For Clojure for example you need to go way back to see a failure (on an external Ant task). The http://build.clojure.org/job/clojure-test-matrix/ job tests Clojure on several JDK versions and you can see that JDK 1.5 was lost in February and seems unrecoverable.

jaycfields/jry · GitHub Jry is a library of helper functions. I trust the source of them (Jav Fields) so I’m going to keep an eye on the functions there for the future. There are a few things I had to copy paste from snippets from somewhere else present here (like update-values in a map or keys) plus some ideas for names I never thought about like -> to denote transform-this->to-that.

Excision | Datomic Datomic is designed following the principle that information is a stream of events that happen and events are never really removed from history. But there are some cases where data are explicit required to not exist anymore, for privacy reasons or other non-technical related requirements. For this reason Datomic can be requested to forget about data using the excise attribute on a specific ID in a transaction. Excision can be based on a specific time window as well. The funny part is that Datomic can’t forget that you asked to forget. So the excision attribute allows to track what was excised but it can’t be excised itself.

Comments (View)
May 7, 2013

Clojure Weekly, May 7th, 2013

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!

Keynote - Jim Weirich - Big Ruby 2013 In this talk by Jim Weirich you’ll find a nice cross language comparison between concurrency frameworks, like the single-thread event-based programming with NodeJs, or the Erlang inspired Celluloid framework written in Ruby, or the Clojure STM. All of that to build a Drone management console application for a customer (hey Jim, please let us know your clients, we want to create applications for them too!). Overall I enjoyed the analysis of single VS multithreaded approached to concurrency and the share memory or share-nothing distinction of Erlang actors. Jim clearly states that the Clojure STM is the most elegant of them all but at the same time it is intimately connected to a side-effect free language like Clojure. The Ruby based solution he explained in this talk is not that different although it requires Ruby implementations supporting OS-based threads (JRuby or Rubinius).

Prismatic/dommy · GitHub The Prismatic team has just released Dommy, an idiomatic ClojureScript wrapper for jQuery and DOM manipulation library in general. Dommy is one of the first library to explore the power of macros to generate JavaScript and the results are exciting. By controlling the compilation step, macros allow for optimised direct access to the relevant DOM api to select elements instead of the corresponding runtime jQuery selector. Dommy provides several other enhancements over jQuery by making use of Clojure syntactic sugar, like sequence manipulation or Protocols. Have a look at the end of this blog post http://tinyurl.com/dxczqkm for more examples.

REPL bootstrap pimpage Welcome to the Clojure REPL world! The Ruby community which is definitely older than the Clojure community, already developed a culture of IRB extensions and tricks. Clojure is following with similar enhancements to the REPL that makes developer life easier. Here’s a list of things you can add to your REPL from Jon Pither’s team ready for copy and paste or reuse.

Erlang (and Go) in Clojure (and Java) This article is quite a technological ride and full of wisdom. Continuations style programming is possible in java using bytecode instrumentation. The solution is not elegant or flexible, but it is one key ingredient for the actor-like solution in Clojure described in this post. It’s also an experiment in bytecode manipulation of clojure generated classes which poses some challenges during the selection of the instrumentation points. Results seem promising with the possibility of implementing “light” threads that can be suspended and resumed. Light threads allow fast context switching and the fork-join scheduler allows for scheduling of tasks off a queue, resulting in a fast jvm-based actor framework. As the author said, Clojure is more suitable for a local actor-like implementation in the small while Erlang implements that better in larger systems.

Comments (View)
April 30, 2013

Clojure Weekly, April 30th, 2013

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!

Bug in locals-clearing in Clojure 1.5? - Clojure 1.5.1 released. What happens when a critical bug is found in Clojure? Here’s a fascinating example of spot-on diagnosis and troubleshooting. It appears that a change to allow loop/recur in catch and finally (https://github.com/clojure/clojure/commit/ddc65a96fdb1163b) generated a memory leak that was spotted from the guys at Prismatic updating Clojure to the latest and greatest. Of course, no apparent connection between the commit and the effects until you test that out in the correct context. It is also evident that Clojure can be treated as a chain of generated languages down to the VM byte code: Clojure generates Java that generates byte code. Sometimes it can be useful to understand this and how to do it yourself especially if the problem is a memory leak. So, now you also know what is the reason for releasing 1.5.1.

Software transactional memory - Wikipedia, the free encyclopedia Clojure implements the elements of STM thanks to the core immutable data structures and concurrency control models like agent atoms or refs. But more in general, STM is an optimistic concurrency model of computation where conflicting changes are handled by re-attempting the same transaction over again. With such a model, locks are not needed. But STM assumes new state is just a function of the past and all the original variations in between are logged and available. Of course this is the definition of pure function in a functional language, so for Clojure (and other FP languages) the STM fits very well. This wikipedia entry explains in a simple way what is STM in general and why in general it can perform better.

Convert Maven pom.xml file to Lein project.clj A juicy handy GIST to convert a pom.xml to a project.clj ready for leiningen. Uhm why would you need such a thing? Say you have this nice Java project at work and you want to start using some Clojure bits with it. Fine, there are all the maven plugins ready for this and it will just work fine. But say that now that you have some Clojure bit in your maven based Java project you would also like to build it using a real building tool like leiningen? Why not, use this converter to create a project.clj ready for that.

Why using Maven for Clojure builds is a no-brainer | cemerick As the title say, Clojure integrates very well with your existing Maven setup. There are projects were leiningen is not an option (which is bad) but at least you can survive with a Maven setup and maybe have your Clojure files developed from inside an IDE that understands Clojure (all the usual suspects). I think this is a very good way to start using Clojure in a Java environment: bring in the maven plugin, have some Clojure developed and let your current Java project talk with the Clojure side for specialized tasks.

Comments (View)
April 24, 2013

Clojure Weekly, April 24th, 2013

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!

(def newsletter) - A Weekly Clojure Newsletter - Home If you enjoy this Clojure Weekly, you might also enjoy another couple of options to receive weekly updates about your favourite language. Today we talk about (def newsletter) that similarly to http://www.clojuregazette.com is promising to “spam” you with good Clojure content every week. Clojure Gazette in particular is different because it has a theme each week around which the links are selected. Thanks to Planet Clojure aka http://clojure.in I enjoy the Gazette anyway. Unfortunately I’m not one of those person who enjoy another email in the mailbox: even if it is great content I just tend to skip them. In that case stick to Clojure Weekly that is delivered to your door through your favourite news reader.

Real Life Clojure Application - Interrupted It’s always a good exercise to learn from the code of others. Notify Me shows a solid Clojure web stack, with Compujure, Clojurescript and Midje for testing, plus a lot more goodies, to send mass sms or emails. It also includes manuals and installation instructions, something that is definitely required for a project that should be used in real-life.

Truly concurrent user interfaces Concui is an UI library built on top of openGL primitives. What makes Concui maybe unique, is the fact that it operates with pure function at its core, a function that given the state of the UI it renders the the actual graphics raprsenting them. It is different from the majority of UI rendering approaches because there is no graph of object hodling the state of the UI but a gigantic structure that is rendered 60 times a second. If you are interested into functional approaches to UI rendering go checkout this project.

Economies of Scala | blog.iterate.no This article is a quick analysis of data coming from online sources and specific questions made to the Java development community in Norway. Although it cannot be representative of the world-wide software developers population is still statistically significant. It basically tell us that: 1. If a developer in Norway is asked what languages would you select for work (not because you like them) Java is coming first, with some scripting languages coming next, Scala somewhere in the middle. 2. If a developer in Norway is asked then what languages would you prefer to use (independently from the market request) then Java goes down the list and Scala is first, followed by Clojure and Python. The bad news for us “clojurians” is that wherever I look, I always find the same situation, with more than half of team already looking into or working with Scala and some people with an interest in Clojure. Is the Clojure community fighting a loosing battle?

Comments (View)
April 18, 2013

Clojure Weekly, April 18th, 2013

Skipped a week, but here’s another issue of Clojure weekly! 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!

The Pragmatic Bookshelf | Functional Programming Patterns in Scala and Clojure I’d like to highlight a new potential addition for your functional bookshelf. The book by Michael Bevilacqua-Linn explores OO patterns translation to the functional world (a parallelism that has been attempted over and over with mixed results, starting from is a non-sensical exercise to you can replace them all in FP with a few simpler ones, see Peter Norvig http://www.norvig.com/design-patterns/) and purely functional pattern, like lazy sequences, tail recursion and memoization. I didn’t read the book myself, but I was wondering if the listed patterns are really what I consider functional patterns: many of them are implementable in OO as well. I would like to see explored instead things at a lower level, like introduce binding, wrapping or http://programmers.stackexchange.com/questions/116395/what-is-the-good-explanation-of-tennents-correspondence-principle

Affordance and Concision | Digital Digressions by Stuart Sierra Another discussion about the dreaded “contains?” function in Clojure. I’ve written already about it and I’ve been bitten several times by expressions like (contains? [1 2 3] 3) => false. Stuart Sierra had that modified with http://dev.clojure.org/jira/browse/CLJ-932 to throw an exception if the collection is not associative. I second that, the previous behaviour sounded more like an hack for some corner case than a real feature of contains?. Now the same problem happens with get on non associative collections: (get [1 2 3] 3) => nil. Of course once you know the rule everything sounds simpler, but it definitely generates confusion. Stuart Sierra is proposing to have the same behaviour for get, throwing an exception instead of returning a nil.

Clojure - java_interop - Type Hints First rule of type hinting in Clojure is that you should only use it when working on pure performance improvement. That means to have in place acceptance criteria for performances in your application, look at time taken to perform some action, maybe some profiling and then decide that type hinting is going to help you out. Type hinting in Clojure is not that bad, but certainly is not as readable as non-type hinted code. It goes even worse when you use overloaded functions for Java primitive types (such as aget, aset on Java arrays type). Having said that, the Clojure compiler is smart enough to understand a ramification of type hints from an originating one, that is, if you type hint the return of a function, the compiler is going to track usages of the returned values and create overridden internal functions accordingly instead of using Reflection.

Clojure libraries for MongoDB, Riak, RabbitMQ, validations, Neo4J, ElasticSearch, Memcached, Apache Cassandra, Kestrel and more Look no further if you’re searching for a Clojure wrapper around a popular service library or utility. It might be already in ClojureWerkz, a toolbox of swiss army knives that is well documented, tested and coded on github. Amongst the others: Langohr (RabbitMQ), Elastisch (AWS Elastic Search), Quartzite (scheduler based on Quartz) and so on.

Comments (View)
April 2, 2013

Clojure Weekly, April 2nd, 2013

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 Reducers In this talk recorded at Skillsmatter during the last London Clojurians meetup, yours truly is going to show you through a live coding session how we can formulate a simple mapping reducer from the ground-up. In the process you’ll see why high order functions are so important in building powerful abstractions.

Illegal Argument - Typed Clojure I listened to this podcast a couple of times already, but I still have to digest it completely. The topic is maybe controversial, or, how to type Clojure, a work Ambrose Bonnaire Sergeant in his spare time while doing his dissertation. I have to admit that after I attended Simon Peyton Jones talking about funky Haskell typing tricks at the last Functional Programming eXchange I see language typing as yet another programming challenge, not an inviolable rule a language must grow with. Core.typed is one of those challenges, how the Clojure compiler can be decorated with type information that can then be used for performance optimisation and of course static type checking. There is still a lot of work to do and Ambrose does his best at describing what the challenges are in this podcast.

Nightweb Nightweb is a p2p network for Android mostly written in Clojure. It demonstrate some decent level of complexity implementing a Clojure app and also Android interop. There are a few challenges still to run the Clojure runtime on Android, like the startup slowness and memory consumption but it also shows the possibility of Clojure on mobile devices. On the other side, Clojure demonstrates solid server multi-threading capabilities as it should be expected. Also look into this project to drive torrent-based p2p networks.

Clochure - A Better Clojure It’s April 1st in Clojure community, so here’s a brand new replacement for Clojure called Clochure that finally solves the number one annoyance in Clojure so far: parenthesis. Try to imagine to program in Clojure without the need to see those tedious parenthesis and imagine instead a world where all that curvilinear non-sense is replaced by square brackets. This is Clochure, give it some love.

Strata 2013: Nathan Marz, “Human Fault-tolerance” - YouTube Here’s Nathan Marz (he was still at Twitter here) with a quick 8 minutes overview about how a system designed to accommodate human failure should work. Immutability should be the “source of truth” of your system, not a mutable database as it has been for the last few decades. Today this is possible (look at Datomic) and advisable. When the source of truth is immutable catastrophic failures can be recovered by playing the same actions over the last snapshot of data. Enjoyed the talk which clearly echoes some of the Rich Hickey’s mantras.

Clojure and ‘Why calculating is better than scheming’ Leonardo Borges does a good job here at summarising why Clojure can be better than a Lisp (in this case Scheme) starting from a paper that Phil Wadler wrote discussing what Scheme is missing as a teaching language compared to Miranda (that along with KRC is one of the main influences behind Scheme). Scheme is of course the driving language behind SICP, one of the principal books for teaching programming for the last decades. Pattern matching and laziness are amongst them but Clojure does a great job at them with core sequences and macros (kind of compensating for the lack of pattern matching). There are others example like this that makes this an interesting reading.

Comments (View)
March 26, 2013

Clojure Weekly, March 26th, 2013

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!

clojure/src/clj/clojure/core/reducers.clj at master · clojure/clojure · GitHub A monoid definition is not as scary as it sounds. It is a set where elements obey three simple rules given an operation that we are going to call “dot”: closure, associativity and identity. It turns out mathematic and computer science are full of such set and if you really want to go deeper, they come with a full blown theory that you can lost years of your life to learn. Clojure call monoid a much simpler concept, a function that creates a function of [op ctor] that when given no arguments invokes (ctor) and with two arguments returns a function of a,b where (op a b) is called. The monoid function is useful to combine back results from a fold in its two argument form and it also works as a custom identity function for reduce.

Refactoring Java using Clojure with the Eclipse Java development tools (JDT) | Maurits thinks aloud Is refactoring easy to implement by a modern IDE? It’s not at all and depending on the grammar you’re dealing with it can be a moderate difficult up to a hugely complicated task. This article describes a simplified version of an already very simple refactoring to remove useless parenthesis from a return call. It targets Java and it requires knowledge about how to create an AST and how to manipulate it. The setup and manipulation on top of Java Eclipse ADT framework is done through Clojure, simplifying the thing with some more terse syntax. An interesting experiment.

bbatsov/clojure-style-guide · GitHub Got this link from @javame on twitter, a nice collection of dos and donts for clojure. The first part is core style that for me is almost completely covered by tooling in vim-clojure. The second part is a collection of interesting idiomatic clojure tips that is worth reading with care (and exercise as much as possible). Probably worth creating a constrained kata of some sort of them.

Programming languages ranked by expressiveness – Donnie Berkholz’s Story of Data Ranking languages by expressiveness is an hard task. This article should be considered an rough approximation for expressiveness based on a few assumptions: commits are based of unit of completed functionalities, a completed functionality has sort of the same scope in all languages, number of lines of codes is a measure for expressiveness (the more lines to express a functionality the less expressive the language) and finally the less lines of code the better is the maintenance of the sources. And it makes all sort of sense really, maybe this is the reason of the few surprises in the results: Clojure is amongst the most used expressive languages, as is CoffeeScripts. Other very popular languages are in the middle and Java is toward the bottom of the scale. Take this statistics with a grain of salt. Of course.

Comments (View)
March 19, 2013

Clojure Weekly, March 19th, 2013

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!

Pedestal Documentation - Build web apps in Clojure Potentially the biggest news this week, Relevancers released Pedestal, a brand new web application framework in Clojure. I skimmed through the documentation but couldn’t try out, will definitely do the next webapp with it. On the surface it remembered me of Compojure or the now gone Noir. It also sounds it is an integrated environment instead, where what used to be the custom made “ring stack” is now a default choice. Can’t say more for now, it is well documented and support on github and google groups. Give it a go if you can, I’m looking forward to it.

Separating code from tests: What is the vision? - Midje I was reasoning about later stages of development, when sources are already in their own files but at the same time I need to add more features. Since I’m not in the test file anymore, I thought I had to abandon my beloved top-down style, the midje “provided” keyword and the powerful “unfinished” block. Fear no more! This quick reply by Brian just tells you how to use unfinished in the source file and also gives you some reasons why you might even leave it after check-in.

tpope/vim-fireplace · GitHub Dear Clojure vim users (I’m not sure, but I have the impression there are just few of us), it seems that the glorious VimClojure life came to an end. VimClojure will be living in several different forms that are converging again to give you the best of the interactive Clojure experience in vim. Fireplace is a nREPL that replace the hg-server nailgun system of VimClojure. Along with it, the static part of VimClojure still lives in https://github.com/guns/vim-clojure-static project. Instructions are provided, I still have to migrate myself (my vim-clojure setup works great at the moment, not sure why I should migrate). If you’re starting today with vim and Clojure wait no more and follow the instruction listed on the github project page.

ClojureDocs - clojure.core/every-pred every-pred is a powerful filter-chaining tool. Say you have a collection of stuff and you want to alter elements based on a set of filters: number? even? or more complicated ones. (filter even? (filter number? ‘(1 2 3 :a :b))) holds up to a point if you don’t have too many filters. But what if you have a long list of filters? (filter (apply every-pred [number? even?]) ‘(1 2 3 :a :b)) fixes the problem for an arbitrary long list of predicates.

Not Lisp again… I enjoyed this reading about somebody who was there when MIT started teaching the Computer Science course in 1983. Lisp was resurrecting again in the form of Scheme and that course was taught until the last year. Not to mention that a book was extracted from that same course, the SICP. The examples in the book are some extracts from SICP up to chapter 1.3 where higher order functions are introduced.

algo.generic/src/main/clojure/clojure/algo/generic/functor.clj at master · clojure/algo.generic · GitHub Updating all values in a map sounds like a common operation in Clojure, but there is no dedicated function to it in the standard library. The closest match is update-in that only updates values if they match the given key. What I’m talking about here is global value update for each key. It turns out the solution is pretty straightforward using list comprehension with (into {} (for [[k v] m] [k (f v)]))) where m is the map and f is the updating function, for example inc. A generic update-values called fmap is included in algo.generic.functor, one of the old contrib now moved to the new repo.

Comments (View)
March 12, 2013

Clojure Weekly, March 12th, 2013

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!

Thoughts on Programming: Logic programming is overrated Logic programming is overrated? I don’t think this is the case. There is certainly hype about it in the Clojure community at the moment, just because people like the intriguing “new” paradigm and they are experimenting a bit with something they don’t know. Is not that different from what is happening in the Ruby community, with people learning about classic OO patterns and trying to apply them. Are they a silver bullet? Of course they aren’t. But there are problems which are solved very elegantly with logic programming, so why not use something that is available and ready for Clojure like core.logic? This post describes a Clojure implementation of a logic puzzle that is solvable without logic programming. It is sufficiently elegant, no doubts. Is that best solved with core.logic? Depending on your level of proficiency maybe yes. Should I always use core.logic to solve typical logic puzzles? Of course not.

3 Things Java Programmers Can Steal from Clojure | LispCast Maybe many don’t realise that consistent part of the Clojure standard library are written in Java (and a consistent part is Clojure as well). It should be then possible to include the Clojure jar and import classes in your Java code right? This blog post is talking about three example of uses of Clojure from Java directly. The usage of Clojure classes is not advisable nor elegant, but as an experiment you can see how it works and maybe there are corner cases where you could use this approach. For example, you could use Clojure persistent data structure today in your Java code or maybe EDN (a better exchange format for data).

Java.next: The Java.next languages Neal Ford was talking about polyglot programming in 2006 already. In this series of articles for IBM DeveloperWorks Neal is introducing three of the most prominent languages that run on the JVM and eligible to be the “Java.Next”. Important concepts like static VS dynamic typing or imperative VS functional paradigm are discussed here. Clojure is certainly the language that takes the most extreme approach compared to Groovy or Scala which is also what enables Clojure the most groundbreaking solutions.

How should I make a clojure STM program persistent? - Stack Overflow This StackOverflow answer describes an approach to durability for the STM. The Software Transactional Memory of Clojure is an elegant abstraction on top of Clojure main data structures to handle concurrency of modifications in memory. As it is completely in memory it lacks the “D” of the ACID properties. You can add Durability with a dosync that encloses changes to the local memory and an agent. Agent are STM transaction aware, in the sense that actions enqueued to the Agent are executed once (even in the event of STM retries) and only at the end of all other successful transactions. dosync with agents is especially good for “write-behind” kind of semantic, where some side-effect that includes potentially blocking IO is send asynchronously to the agent to be executed only once if the transaction succeed.

Clojure, concurrency and silver bullets « Otaku, Cedric’s blog Cedric’s blog must be one of the most read java-based blog around. I used to follow Cedric in 2005 maybe? It was already a good read. Cedric is an exceptional engineer and his blogs tend to be provocative. And it’s not the first time I read some negative comments about a new technology or language on Cedric’s blog which is lacking evidence. Cedric thinks that Clojure STM or Agents or Scala’s actors are not a silver bullet for concurrent programming. Probably they aren’t, but they are definitely a better level of abstraction for many of the concurrency problem (like objects were at describing real world simulations). Stuart Halloway’s comment at the bottom probably summarises my thinking the best. At the same time I’m pleased to see sometimes provocative blog posts like this one although they lack evidence. Now 3 years has passed since 2010 (the time this blog post was written). Are we there yet?

Comments (View)
March 5, 2013

Clojure Weekly, March 5th, 2013

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!

Clojure Futures | Object Commando I already introduced Clojure “delays” last week. One main difference between the two concurrent construct is that delay executes their body only when lazily evaluated while futures go executing their stuff as soon as you create them. Futures are basically the Clojure alternative to java native threads, which includes creation of the Runnable and invocation of the run() method but with much more syntactic sugar and features. Futures are a good fit to start some expensive computation while the main thread can detach and do something else. Futures supports a timeout on deref (deref (future…) 1000 :toolong) will print :toolong if the future takes more than 1 second. A difference between a future and a native thread is that futures come from a thread pool which is shared with other potentially blocking actions. You don’t get the thread pool by default with native threading in Java.

How to use “Update-in” in Clojure? - Stack Overflow As many other Clojure standard library functions, update-in was specifically designed to update nested values in a map. Please note the important fact: sometimes by looking at Clojure doc documentation for a function is difficult to understand why it’s there and how to use it. This is often because the function is missing the important information about which problem was trying to solve to begin with. The StackOverflow answers exactly the context of update-in usage. Without update-in you need to to read access the map, create the new value, store back into the map. Update-in is the more idiomatic way to do the same operation.

kotarak / ClojureCheck — Bitbucket QuickCheck is a form of generative test framework written in Haskell. QuickCheck works by identifying “properties” which are roughly equivalent to rules governing a feature. So if the feature is called “inverse” and given a list it returns the same list in the opposite order, one fact that is that the (inverse (inverse list)) gives the initial input list. QuickCheck let’s you define this property as a function and then it generates random list to verify if the property always holds true. Properties nicely describes a feature illustrating few important facts (or specifications, or scenario). I’m using the term scenario to capture the affinity between QuickCheck properties and Cucumber scenarios. ClojureCheck is a small library implementing QuickCheck concepts for Clojure. The property is expressed in terms of a few variables and their domains and ClojureCheck runs the property several time randomly choosing values from the allowed ranges.

The Deep Insights of Alan Kay - mythz blog A great collage of excerpts from several papers from Alan Kay, inventor of SmallTalk (one of the best interpretation of OOP so far) and many other “concepts” that ended up in commercial applications. Alan Kay has a deep respect for LISP. In his opinion, the millions LOC necessary for an application like a word processor or a spreadsheet are necessarily a complexity problem that got out of hand. “The web is a joke” compared to TCP/IP, a 20k LOC software that is powering communication between millions of computers today. LISP (in the broader sense of “lispy” languages) handles complexity through expressiveness and conciseness and along with SmallTalk is one of the best languages to implement messaging. A quick personal note: there are countless examples in nature of systems governed by few simple rules that can generate almost infinite complexity: cellular automata, fractals, DNA. It seems that we are still missing that kind of revolution in programming languages.

Comments (View)