September 17, 2014

Clojure Weekly, Sept 17th, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

Learn Datalog Today! Notable initiative. Despite being some 30 years old, Datalog is not as known as the distant cousin SQL. It has a steep learning curve if you never touched any Prolog or being exposed to rule engines and there is a lack of modern approaches on how to learn it, especially step by step guides. These days Datomic is proposing Datalog as the main query language. This website seems that missing resource including nice exercises at the bottom. Thanks to Jonas Enlund and the summer rain of 2013 for putting this together. Clojure Bookshelf I knew about the Clojure bookshelf but never bookmarked here. This is Rich Hickey’s collection of recommended books, including the indispensable hammock for a more comfortable reading experience. They are recommended in the sense that they were in Rich’s reading list starting before the first Clojure work and somehow contributed to this successful language. Definitely have a look here for some background on some the most advanced Clojure features.

There’s a Spectrum Involved Here (Brandon Bloom) I was a long time listener of GiantRobots podcast back when I was into Rails and then stopped listening at some point. I rediscovered recently many interesting interviews are going on there, including people from the Clojure and functional community. Like this episode with Brandon Bloom that I know by fame on IRC and the mailing list. He likes to get things out quickly and this approach reflects in his language toolset. He likes to start playing with an idea with rule based languages like Mathematica. He prefers more structure with dynamic functional languages (Clojure) and only add typing later on (if needed). OO is also considered but not design the entire system. In this sense OO is very good ad describing closed systems (what happens inside an object) but it gets difficult to manage when too many interactions happen (the entire system). The spectrum in the title is any dogmatic approach to development where a language or framework is used out of context.

Ants: Clojure vs. Common Lisp - Google Groups From the oldie but goodie series, this is a juicy discussion on comp.lang.lisp about advantages and potential pitfalls of software transactional memory implementations. It all start with Pascal Costanza (of Lisp fame) reproducing the ant colony example in Lisp using locks and the claim that is not that complicated to reproduce Clojure features. Of course Rich chimes in right after. What the ant colony example can achieve is not clear at first sight, but the fact that it doesn’t deadlock or waste system resources is something that is not easy to achieve.

PDF Links #Clojure IRC Crowd sourced PDFs from the very special people in the Clojure IRC channel. Some of them are not relevant (see Object Oriented Cobol book!) but on average the CS papers mentioned here constitute the theoretical basis of many of the Clojure features. There are also papers from other languages for feature comparison, interesting slides from talks and much more. I’d really love to do something similar using the clojure-ml as a source if such an archive existed somewhere!

palletops/lein-uberimage Interesting stuff. This creates a Docker image to run your Clojure app. Useful to distribute a JVM with the app, something that is not always a given for all platforms. I assume you can also customise the created docker image to get other stuff on board, like Redis or ElasticSearch. That is much easier to distribute than install every time!

[PDF] Inside Channels - EuroClojure 2014 - Rich Hickey I was there watching the talk live, but this talk Rich gave at EuroClojure is very dense and deserve a few more passes. Also because there were technical problems synching the slides, the only way you have to watch Rich giving the talk and also look at the slides is to use this pdf that Alex Miller made available on the clojure ML.

Matthew Flatt - Cognicast Episode 061 — Cognitect Blog This Cognicast with Matthew Flatt is full of goodies. I’ve used Dr.Racket and Racket a bit for my SICP studies and I’ve been impressed by what IDE can achieve (and what I’d really love to use daily for my Clojure dev). Racket is a Scheme dialect and it doesn’t run on top of the JVM. This means 20+ years of complete freedom to evolve the language in any possible direction, including things that Clojure can’t support (like TCO or continuations). I like to think that Racket is what Clojure could evolve into (in terms of features) if there were no JVM constrains. Matthew is concentrating lately on the macro system that he’s got idea how to re-implement from scratch. Something they’ve done already is the complete access to the compiler view of the scope at macro-expansion time, something that resemble an compiler-API that is used both at compile time and runtime.

Comments (View)
September 10, 2014

Clojure Weekly, September 10th, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

dedupe - clojure 1.7 Randomly selecting bits of the soon to be released Clojure 1.7. dedupe iterates through a collection keeping only one of the potentially consecutive duplicates found in coll. So: (dedupe (interleave (range 10) (range 10))) is again (range 10). As many other collection functions also dedupe gets the transducers treatment. When invoked without arguments returns a transducer that can then be stack up in a chain.

transducerfun.clj This Gist by Rich gives an example of what can be done with transducers, staking up a pile of operations in the xform transducer to be used in many possible ways: making it a normal lazy sequence, creating a recipe over specific data (with iteration), reducing it or making it into a vector (no laziness) or using it in a core.async channel. If you want to try the snippet on master, just replace flatmap with mapcat.

Eric Normand - Cognicast Episode 062 — Cognitect Blog Interesting episode with Eric Normand of Lispcasts and Clojure Gazette fame. Eric has an amazing background. He did common lisp extensively and a couple of years of Haskell professionally and now he’s concentrating purely on Clojure. With that background the amount of links to good literature that Eric gives is amazing (on this podcast and on the Gazette) as it is his point of view about typed and dynamic functional languages. His last effort is, a continuation on his educational activity started with Lispcasts.

counted? - Clojure Documentation counted? function in the standard library is one of those about capabilities of data structures. It returns true if you can execute a count on a collection in constant time. But without looking at the sources it is quite confusing. For example counted? on an a java array of ints will return false, but it invokes Java native length underneath that is of course constant time. So the interpretation of the doc is more something like: if coll is a Clojure collection it tells you if it counts in constant time, if it’s not a Clojure collection it will always return false. The source is indeed just checking that the type implements the interface Counted.

JVM Language Summit 2014 The JVM language summit conference is mainly about language implementations on the JVM and low level features that Clojure programmers are not supposed to be interested in. Anyway if you are interested in the kind of stuff Clojure can take advantage of in the new releases to be better and faster these videos/slides are for you. You can also go back 3 years worth of content. Pay particular attention to Guy Steele, Cliff Click, John Rose. Rich Hickey is present with Datomic in 2012. Happy viewing.

Comments (View)
September 3, 2014

Clojure Weekly, September 3rd, 2014

Welcome to another issue of Clojure Weekly. I missed a couple of weeks for some holidays but now I’m back lurking the interwebs. Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

Feature Expressions - Clojure Design - Clojure Development Feature Expressions is currently a “maybe” Clojure feature which is under discussion on the wiki (along many others). The idea is borrowed from the equivalent Common Lisp feature that solves the problem of targeting different platforms with custom language constructs so a specific expression will be compiled only when on a specific platform. Clojure has been ported to at least three major platforms, the JVM, .NET CLR and JavaScript engines and still offers close relationship with the hosting platform, allowing for specific host expressions (java interop is quite powerful for this reason). A similar approach was attempted successfully with lein/cljx.

The Compiler, the Runtime and other interesting “beasts” from the Clojure codebase - Renzo Borgatti on Vimeo After some delay, all the EuroClojure talks videos are now available, including mine that is linked here. Pity that there is no slide to screen sync, since I’ve used animations for code scrolling that won’t be visible. Many people told me it was an interesting talk, go see yourself. :)

Guillaume Marceau: The speed, size and dependability of programming languages This is the amazing result of comparing 33 languages over 429 programs. Each program has been written in each language and the article compares size (LOC) and speed. If you look at the results of functional languages, the conclusion is that being functional does not have an impact on performances. The biggest impact on speed is how mature the runtime of the language is. So there are languages that are really expressive but not a lot of investment was done to make them faster and the other way around. Sweet spots are for example Lua and Haskell.

The Last Line Effect An interesting point of view is described in this article, somebody who search bugs professionally but is not really a tester. The kind of bug described here has to do with the copy paste of single lines to repeat the same behaviour with different values. The article claims that bugs in the last of this mechanical repetition are 4 times more common. Not strictly Clojure related, but my thinking here is that this bug is typical with imperative programming and much less of a concern with FP, where with immutable structures the same code is written concatenating functions.

Clojure Cup 2014 Another edition of the ClojureCup is coming this year, 27-28 sept, with sing-up starting in 3 days. This is a coding competition where teams have 48 hours to complete a (web or otherwise) Clojure app. If you have a weekend to spare and some idea with you and your colleagues this is the perfect time to signup and code some Clojure and maybe push even higher and create your own startup.

SICP Distilled by thattommyhall — Kickstarter Worth mentioning that Tommy Hall is organising these screencast series (and possibly other formats) about the content of this popular book, using Clojure as the main dialect. The goal is to distill the most important part of SICP making it easier to access a book that is conceptually very dense. You don’t need to pledge a huge amount of money to make this happen, so please go ahead and contribute.

CUFP I heard about CUFP (Commercial Users of Functional Programming) conference a little too late to be useful for this post, but it sounds like an interesting conference to track about FP. There is no Clojure presence as far as I can see, but this could change next year. The list of tutorials is extremely interesting, with presence of all major and some esoteric language as well. Will have a look after the conference to see if videos of the talk are available.

Comments (View)
August 14, 2014

Clojure Weekly, August 14th, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. 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 Documentation For the unknown pearls in the standard library, this week I’d like to introduce you to This namespace seems dedicated to diff because the other functions seem to be internal implementation details. This is a polymorphic diff that based on the input params is doing its best to return the diff as seen from both sides and the actual difference as the third part of the results. It can be used for all sort of useful stuff related to comparing data structures with a result that is easy to process.

Functional Geekery Episode 13 – Martin J. LoganFunctional Geekery | Functional Geekery This FG episode is about Erlang, sorry to file it under Clojure stuff. But it is an interesting and entertaining episode with Martin Logan, an Erlang veteran, illustrating a bit of history of the language and its community. Although Clojure doesn’t embrace the actor model as a fundamental concurrency construct, there is certainly inspiration coming from that with agents in Clojure and they both share immutability as their core principle. Also consider a quick look at Elixir, a modern take to Erlang with a more Ruby-like syntax.

Promise - Clojure Documentation Promises is another Clojure construct to help in creating powerful concurrency models. It doesn’t contain behaviour for a computation (like futures) but it is just delivered results with deliver. Promises are often found in conjunction with futures since the behave like single-entry blocking queues. The future can deliver to a promise that is passed in when the future is created and the main thread can at some point block while deref the promise. The advantage is that you don’t need to code any nasty “wait” semantic (like futures). There is also another important aspect of combining futures and promises this way: the callback fn can be generic and the result handled to the promise in-situ, creating the semantic of a synchronous call. The same happens as well in core.async, but the thread where the computation is running is non-blocking.

Dissecting Reducers - Skills Matter If you’re struggling understanding the new transducers primitives that Clojure 1.7 will be introducing, I strongly suggest you get your self familiar with Reducers first, because the implementation of the transforming reducers (map, filter etc) is exactly the same. This is also a very nice example of functional abstraction or “pattern” approach to functional programming that is worth understanding deeply. What I’ve linked here is a talk (30’) I gave last year about reducers from the point of view of functional abstractions (more than the parallelism they introduce with fold).

Some trivial examples of using Clojure Transducers - An Ostler in IT Of all the transducers buzz I’ve found around I’ve selected the following post because it’s mainly examples. Like the author of the post, I’ve also found transducers a natural evolution of reducers and after I went beyond the new lingo I felt myself home again. One important difference that you can clearly see here, is that reducers are not able to apply a pipeline of transformations without actually “reduce” the collection. The only way to achieve that effect is with “into” that uses reduce internally completely throwing away laziness. Transducers effectively abandons the intimate relationship with reduce (and fold).

Comments (View)
August 6, 2014

Clojure Weekly, August 6th, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

Recommended Reading : Microservices Architectures and Clojure (A Quick Survey of Resources) | Architecting Beyond Twenty Twenty In this post you can find a list of micro services related material (presentations, videos, articles) with a specific focus on Clojure solutions. Why all this interest about micro or nano services? Because it adds quite a bit of freedom in terms of composability and scalability of a system. Micro services are also easier to deploy compared to a monolith application, where keeping track of what is going live isn’t an easy task at all. Clojure is perfect platform for micro services, because it’s dynamic (quicker feedback loop), run on the JVM (widespread) and contains mature deploy tooling and monitoring (including everything that was developed for Java already).

Prismatic/eng-practices Thanks for sharing Prismatic! These are interesting and detailed readings about the engineering practices Prismatic has been implementing and evolving on the field. This is the main reason they are concise and to the point. You can find here at the moment some elaborate discussion about Clojure type of polymorphism, namespace organisation and testing. Not strictly related to Clojure but definitely worth a reading as well: Prismatic git workflow and iOS profiling.

bellkev/dacom A Datomic, Compojure, Chors, core.async, Om stack ready to hack with. If you resist the temptation to update the dependencies to the latest and greatest (please do yourself a favour and don’t touch them until you’re missing a feature) this project works out of the box and contains a working stack with the above technology nicely integrated and automated. It uses Bower, Boostrap and LessCss to automate the client side and it also contains lein tasks to prepare and initialise the Datomic instance and Austin integration for ClojureScript. If you don’t like the idea of cloning it, just go for the “lein new dacom” template and the app will get your name. Well done.

johnwayner/lein-datomic If you prefer just Datomic automation, this small plugin contains a few useful tasks integrated with leiningen. Given an existing project it adds commands like the Datomic instance start or re-initialisation with the schema configured in project.clj. Documentation is essential but clear. Also easy to fork and extend.

Anna Pawlicka | Common mistakes to avoid when creating an Om component. Part 1. Nice collection of Om pitfalls, things that are easy to not understand correctly and (usually) silently fail. At least, this is also my initial experience with Om and ClojureScript. One part of the “fragile” impression is definitely the learning curve, which includes something that is similar to a new programming paradigm (reactive programming is a little bit, especially if you add lifecycle events to deal with state changes). But the other part is more about the fact that the technology is really young and tooling around it fails if you use a different minor version.

Comments (View)
July 23, 2014

Clojure Weekly, July 23rd, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. 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.core/gen-class · Grimoire gen-class creates a Java class and spits that to disk. It can be instructed with all sort of Java goodies, like implemented interfaces, methods, ctor plus some goodies like a post-init constructor. One of the main reasons of gen-class is Java interoperability, where it is important that the class is not generated on the fly in a deeply nested classloader and is reachable through normal class path lookup such as Class/forName calls. gen-class has only value during AOT compilation and does nothing at the REPL.

Transit – A format for conveying values between different languages | Hacker News Transit is a new data transfer format from the Cognitect crew. What it offers and what adds to the plate of an already rich horizon of data transfer format was not clear to me after reading the official presentation page. As usual HN does a great job comparing with the existing stuff and hence my link to it. Rich, Fogus and Swanndonnette are all in the thread, so you can see that the competitive advantage of Transit over other formats seems to be about the compression mechanism, pluggable human-readability, json interoperability and the extension mechanism. EDN isn’t deprecated or anything like that, but it sounds like for future work you better look at Transit instead.

cemerick/austin Austin is the glue between the lein building process of a ClojureScript based project and the browser. With Austin things like evaluation of ClojureScript in the repl is possible, with several options, headless or fully integrated with Chrome for example. I think the most compelling use case during development is making a change and have the browser to automatically update the changes, no refresh required. Other compelling reason is full access to the dom at the repl for debugging and experimentation.

One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages Totally cracked up by this humorous history of programming languages :) All the stereotypes are there. Probably the one I liked the most is Perl. I think ARC got mentioned instead of Clojure because in 2009-ish it was still considered the new Lisp. History turned out to be different.

CLiki: Naming conventions These are the naming convention guidelines you were all waiting for! It’s common lisp, but hey, it is not that different from the same kind of naming conventions of Clojure sources. Of course they are not all applicable, but they help a lot giving just a bit of semantic to a function name in case Clojure doesn’t.

Okasaki: Ten Years of Purely Functional Data Structures A blog post from Okasaki, author of Purely Functional Data Structures, describing the history behind the book that is still popular these days. Okasaki also answers a few frequently asked questions. StandardML was selected for specific reasons related to its control of lazy VS strict evaluation but it won’t be the same choice today: the book would likely be re-written in OCaml. Why not a dynamically typed language? Because Okasaki thinks that functional data structures are better explained when types are explicit. Just in case you don’t know, Clojure is implementing and extending some of the persistent data structures described there (in Java). If you want a preview of the book before buying, keep in mind that Okasaki’s thesis is available online with a very similar content. Worth learning SML just to follow this book! Unfortunately, no 2nd edition is in sight.

How to write a dissoc-in command for clojure? - Stack Overflow There is no dissoc-in in the standard library. There used to be one in clojure.contrib that got dispersed when libraries entered their own repos. But it is also simple to replicate with an update-in as suggested in this SO answer. You just need to stop one key before in the list of inner keys and add it to a dissoc invocation for the corresponding map: (update-in {:a {:b 0 :c 1}} [:a] dissoc :b)

Comments (View)
July 15, 2014

Clojure Weekly, Jul 15th, 2014

Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

Functional Geekery Episode 12 – Adi BolboacaFunctional Geekery | Functional Geekery Controversial (in a good sense) Functional Geekery episode. When speaking about style and idiomatic Clojure, I tend to be inspired by one of the most popular source of Clojure wisdom: clojure/core.clj. The style there leans toward essentiality, where variable names are just a few letters and they tend to follow an implicit convention (f, g are function names, xs is a collection of x and so on). But uncle Bob clean-code style is much more verbose in that respect, suggesting more speaking names. I agree with all the rest of the discussion, in term of SOLID principles applied to FP and the overall idea to dedicate a code-retreat format to FP style programming. But I’m not sure about naming. What determines understandability in a language is also the culture and conventions that are stratified into it. Clojure is inspired by CL in many ways, including naming and it looks unproductive to me to try to change 50+ years of conventional wisdom to another convention.

rseq · clojure.core For the “standard library in small pills” series, here’s the mostly unknown rseq. It works like seq, transforming something sortable into a sequence but at the same time it is reversing its order. Use cases? None at hand, but consider that it is doing it O(1). How can it be? Little trickeries: the PersistentVector underneath is unchanged, but is wrapped in an RSeq object that is counting backward when next() is required, starting from the end! Good luck garbage collector when I unroll 1M of these :)

protocols - How does clojure’s defrecord method name resolution work? - Stack Overflow Enlightening quick SO answer from Christophe Grand about potential name clashing in protocol definitions. defprotocol and defrecord are a powerful tool provided by Clojure to replicate some object oriented runtime polymorphism. They’ve got rough edges as soon as you start pushing too far with them, something you can experience if you try to port a complex object model from Java “literally”. defprotocol for instance, creates the function definitions inside the namespace they are declared in, with the consequence that there shouldn’t be other “normal” functions with the same name and no other protocols definitions with the same name, let alone using function names from clojure.core. At the same time if you define protocols in different namespaces you can incur in weird require+import constrains to use them in other places. Add the fact that other than the basic examples, there is no throughout guide to “build yourself a CLOS in Clojure”. We can certainly discuss if this is needed at all…

lein test-refresh If only I knew about this a couple months ago… I wouldn’t have ported the test suite to Midje with autotest, my favourite unit test framework. Or maybe not, because I’m quite fluent with the Midje API and got used to the expressiveness it can provide. Anyway, if you are on clojure.test, this lein plugin is an automatic runner that runs in the background and send you notifications about the status of the tests while you are typing in the editor. It is my favourite workflow at the moment, which includes the REPL running for experimentation and solutions while the overall functional interface is driven by tests. I don’t use the same for legacy code, where somebody else wrote it, although I tend to cover “after” with test the part I don’t understand.

L(λ)THW Learn Lisp The Hard Way Interesting initiative that could be ported to Clojure and has already been ported many times to many languages. Zed Shaw started it all (I think it was Learn C The Hard Way) and then produced another bunch of them. The template to write books using the same style is publicly available and Zed Shaw is encouraging others to write their own. This is the “brave” Lisp attempt, considering the amount of top quality books around about programming in Lisp. The author explained the effort behind this achievement on HackerNews. This is not a couple of days project and it is coming out nicely. Remember the following rule of thumb: learning Lisp is providing you the all principle (and often nomenclature and conventions) behind Clojure.

clojure.core/cycle Cycle is similar to clojure.core/repeat, but it operates on a sequence by recursively merging it to a copy of itself, ad infinitum. Cycle is your friend on things that needs to be provided in a round-robin fashion, including assignment of a finite set of identifiers or simply creating a css zebra list of some sort. Repeat is less useful here since it will repeat a single item instead. Always use with clojure.core/take on front!

Comments (View)
July 9, 2014

Clojure Weekly, July 9th, 2014

Welcome to another issue of Clojure Weekly! I’ve got tons of ideas and resources to follow coming out from EuroClojure, I’ll be digesting them here during the following weeks. If you don’t know what this is, Clojure Weekly collects a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

My Top Clojure Articles - Adam Bard and his magical blog Signalling a nice collection of Clojure related articles by Adam Bard. They are divided by level of proficiency with the language, so it makes it a very good start to pick up Clojure from scratch.

EuroClojure’s Videos on Vimeo Unless they are already displayed when you read this, keep an eye on the EuroClojure channel on Vimeo because videos will appear very soon here. Go for David Nolen for the inspirational talk, Tommy Hall for the entertaining one or yours truly (Renzo) because this is a shameless plug!

Thoughtworks technology radar The last technology radar sees ClojureScript in the trial phase, up to the top close to the adopt section. Clojure the core language is not present, while Scala is in the adopt section. Clojure (Om-ClojureScript) is present in the explanation section as well. My impression is that TW is not endorsing Clojure as a server side language but as client side, which is amazing and disturbing at the same time (or as someone else put it on twitter, it is given Clojure as implicit adopt?). There are other well known technologies and platforms, but there are also new entires I’d like to have a look at.

Grimoire Grimoire is a new documentation service and community contributed example repo similar to still comes up high in google searches despite it is documenting Clojure 1.3, by providing examples that are not easy to find elsewhere. Grimoire is instead up to date and also gives access to all the examples in clojuredocs. Grimoire is open to community contribution over git pull requests and will likely be improved in the future to make contributions easier.

Difference between defrecord and extend - Google Groups This interesting thread finally solved my problem. Extending a type to a protocol is not equivalent to a defrecord definition that implements that same protocol. They generate different kind of polymorphism. The first main difference is that extending a type with a protocol is not adding functions to its interface (and this you can’t invoke them on a record instance). Second main difference is that extending the type with a protocol allows for an implementation swap at any point, while defrecord definition of functions are forever.

Clojure - todo Another small bit of history, a Clojure todo list back from 2009. Is not very important today but I want to keep an handle to things I discover randomly just in case. Interesting to notice that 90% of what we are talking about nowadays with faster compilers for mobile or Cloj in Cloj were already there. Others like Datalog were not baked in directly in the language but in Datomic.

Clojure Gazette 1.81 - Nicola Mometto I’m very interested in everything compiler related these days and of-course I’m following the amazing work Nicola is doing to port Clojure in Clojure. This Clojure Gazette is an interview with Nicola that explains a little but of the background about his work, past, present and future. I hope we’ll be soon meeting Nicola at some Clojure conference speaking about the work he’s doing, but as he said in the interview, he’s mostly spending his time coding and the better way to know about his work is to follow the public activity on github.

Comments (View)
July 1, 2014

Clojure Weekly, July 1st, 2014

Welcome to another issue of Clojure Weekly! I’ve got tons of ideas and resources to follow coming out from EuroClojure, I’ll be digesting them here during the following weeks. If you don’t know what this is, Clojure Weekly collects a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

midje-doc Midje-doc generates beautiful documentation starting from midje facts, which are treated as examples to show how code works. There is some directives you can give during namespace declaration to tell midje-doc how do you want your tests to be translated into “live documentation”. Midje-doc supports the midje :autotest philosophy and can show how the documentation shapes up while facts are being written. There is a 14’ screencast to demonstrate all of this on the github repo page.

[GSoC 2014] Lean compiler: first iteration - Clojure on Android Quick one to signal that project Skummet is now able to output static declaration of Vars in the generated Clojure byte-code, one of the several optimisations envisioned for Android environment that could have also beneficial impact for quick development feedback at the REPL. I tried the build on my own projects without noticing any errors.

Lisp in Small Pieces: Christian Queinnec Just ordered a copy of this (quite pricey) book about Lisp implementations. I found the book linked in many places, including rhickey suggesting it on IRC (5 years ago). The content is about typical problems and solutions for implementation of lispy-like languages (Scheme is the one used in the book), including compiled output, intermediate bytecodes or interpretation. The Rich Reference Implementation of Clojure is indeed all about this sort of problem.

metaprogramming - How do you evaluate a string as a clojure expression? - Stack Overflow I had to use something similar recently, so I could pass around a macro to be used in a different place from where it appeared in the code. With normal functions you can always use (var fn) or the equivalent #’ reader macro to create, for example, a map of keys - fns. But macros need special evaluation and thus something like (@#’clojure.repl/doc str) doesn’t work while (@#’clojure.lang/+ 1 1) is perfectly fine. The only (not very nice) way I found was to use (eval (read-string “clojure.repl/doc str”)) to make it work. Mind that there are very few cases where you need something like this, which is also suffering from security problems if eval-ing user input.

Euroclojure 2014 Here are the definitive notes for EuroClojure. Phil Potter wrote all of the notes at smoking speed over the conference, except during his own talk (I’m sure he’ll fix this annoying detail next year :) By the way, talks were amazing, with tons of ideas and links to follow that you can read on this gist as well. Thanks Phil!

Comparing Clojure Testing Libraries: Output - Jake McCrary An interesting comparison between output of testing libraries. Expectations is the winner of this informal but still useful comparison, mainly because of the care that put into the correct formatting of output between different data types. Midje is coming last with a promise (see comments below) by Brian Marick to make it better than ever. Can’t wait.

quil/quil Quil is a Clojure wrapper around, which is a drawing language and environment written in Java. With a few more wrapping layers on top, we are talking about driving openGL from Clojure. Quil is suitable for all your graphical and animation needs down to the pixel level, with a huge library of primitive available for more abstract drawing. I saw it in action during the interlude lunch-time lightning talk, showing tracks of a sequencer on the screen in a simple and effective way.

Comments (View)
June 24, 2014

Clojure Weekly, Jun 24th, 2014

Welcome to another stellar issue of Clojure Weekly! This one is just before my talk at EuroClojure. Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!

lazy evaluation - Clojure: rest vs. next - Stack Overflow Nice discussion on StackOverflow about next VS rest. It can get quite philosophical and reading the sources is not helping a lot (I could only track that is calling next() inside but each collection has a different implementation of this). One sure thing is that to return nil next needs to look ahead and realise at least the next element or the next chunk of a sequence. So rest is more lazy than next.

clojure-compiler/src/net/n01se/clojure_compiler.clj at master · Chouser/clojure-compiler Another bit of Clojure history. Chris Houser is one of the protagonist of the Clojure scene and one of the earliest receptor of Rich’s ideas about the future of Clojure. Apart from his very good book ( he should also be credited for a couple of important early attempts: ClojureScript and Clojure in Clojure. Although his work didn’t end up being part the current related efforts, it is stil inspirational. Linked here is a clojure compiler in clojure from 2009. If you look at the bottom, it is tested by parsing the compiler itself.

Pelure - Shell Scripting in Clojure with Pallet is an internal clojure DSL that emits bash shell scripting. Personally I don’t write a lot of shell scripting, just the right amount when needed and when that happens I’m definitely going to look up yet again how I need to implement a condition or a loop. No more with Stevedore. I just write my favourite Clojure with some imperative style and voila, I can output shell scripting. Maybe that could be the base skeleton to start with. It allows advanced “macro style” scripting, with quoting pure Clojure to express some more complicated stuff that doesn’t necessarily belong to the DSL language. Cool.

ClojureDocs - clojure.core/group-by And just when you were abandoning all further attempts and accepted to use a fairly understandable “reduce” here comes the group-by. The name speaks quite clearly: give it a list of maps and a key and group-by will group those maps by the value of that key. The reduce is still there in the sources but handed gracefully and with an eye on performances by the standard library. If you open the sources you’ll see that it is assoc! a transient map to build up results and make it persistent at the end.

More Open-Source Clojure Systems, Please uSwitch is a neat Clojure shop in London and they recently decided to share some of the goodies they are producing over there. This post also illustrates a few of the Clojure infrastructure best practices and tools they adopted, including a component system, riemann monitoring and much more. The post is also an invite for all the other Clojure shops to open-source more of their work. I couldn’t agree more. At the Dailymail I started taking care of this part a little more and open sourced the first of a series of libraries/tools that are part of our daily practice. But we still have a lot to do in this direction. Stay tuned and share more.

ClojureDocs - clojure.core/comment comment is a macro that ignores the given body and returns nil. When comment is used in normal code it still needs to go through the reader before macro expansion inside the compiler when it is finally yielding nil. This has the important consequence that what is enclosed in a comment needs to be well formed, at least for the syntax checking that the Clojure reader is applying. For example the following: (comment {:a a :b}) won’t pass the MapReader check, because the reader knows nothing about the behaviour of the comment macro. The #_ reader macro ignores the next form and doesn’t force any compiler step, so it is usually a better choice.

Comments (View)