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!
TDD is dead. Long live testing. (DHH) Not strictly Clojure related, but the discussions about TDD vs REPL driven development is still hot in Clojure-land. DHH here is publicly declaring that TDD is dead. I saw the tweets coming from the keynote at RailsConf and I’m looking forward to the Rails community reaction. DHH was never a fan of TDD but he was sort of doing it in the past, without realising exactly what was wrong with that approach. This blog post explains why he now thinks that TDD is just like learning wheels (oh, I so wait for Uncle Bob’s write up!). What’s my take on this? I still start test first, I can’t resist, but I’m much less strict than the past. I quickly abandon it as soon as third party services are invoked, or some piece of infrastructure that requires a lot of stubbing is required (like a rest endpoint for example). This is when I abandon TDD and use the REPL to play with the app. Mind that I’m also using the REPL throughout development, to create the implementation that makes my tests green. Still happy with that, it helps me think and focus, exactly like this weekly writing.
keyword parameters? - Google Groups Old but interesting discussion about named parameters for functions. I already talked about defnk in the past and it was abandoned after migrating out from clojure contrib. Still it is an interesting little exercise to see how simply the feature can be added to the language (something that happened for Ruby properly in 2.0). Rich is showing the code in the last email. With this macro you can define functions that declares parameters with a name and a default. If the last two parameters in the example are not given (or others are given), it takes the default. The only way to change that default is to prefix the keyword to the parameter. The only caveat, at least in this simple implementation, is that the named params need to be at the end.
Decompiling Clojure I - Interrupted This is the start of a very interesting and well written series of article about Clojure internals, the relationship with Java and the produced byte code. It doesn’t assume previous knowledge of any of the above which is very good if you never decompiled a class file. The last part explains the additional information that the compiler can add to the byte code to help the JVM during debugging (for example). Next instalment will be about the compiler and reader and I’m looking forward to it.
ClojureDocs - clojure.core/or “or” can be used the standard way as in many other languages. But since nil is false in predicates, “or” can be also used to handle those frequent cases where some parameter can be nil and a default can be provided. (or mime “application/html”) for example could be used to accept a given mime variable or use an application/html default when mime is nil. That is equivalent to the more verbose (if mime mime “application/html”) which is not as nice to read.
The rise of functional programming in Banks | Oxford Knight Blog An interesting non-technical point of view from a recruitment firm that is investing a lot in the field of functional programs. The post sates that the raise of FP especially in banks since 2006 can be related to the fact that it models concurrency better, it models math better and that skills learned on the JVM (of course Scala and Clojure only) can be easily sold to other OO-based businesses. The last part reports back on teams adopting the main five FP languages: scala, clojure, haskell, ocaml and F#. No mentions for Erlang (always talking about banks, hedge funds and investment banks in general).1 day ago