October 15, 2014

Clojure Weekly, Oct 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!

Expert to Expert: Rich Hickey and Brian Beckman - Inside Clojure - YouTube Good introduction to Clojure by Rich himself talking with Brian Beckman. It also goes beyond the basic introduction when Clojure is compared to other languages of the ML family (for example Miranda or ML itself). Rich also gives an overview of persistent data structures internals and concurrency mechanisms.

gensym - Clojure standard library gensym is a little function that generates an unique symbol name (in the current running process). It optionally takes a prefix that will be used along with a sequential number added to the name. The main use of gensym is to write hygienic macros because it prevents clashes with environment bindings that are already in place at expansion time.

locking - clojure.core Programmatic locking is not in Clojure. Thread synchronisation and concurrency are handled at a much higher level with atoms, vars, refs and agents. But just in case you need to go low level, the locking function is still less verbose than the Java version that requires the synchronised keyword around an object instance. One use of locking could be if you use deftype with an unsynchronized-mutable field and then you need to protect updates with a lock. Use if you know what you’re doing.

gasc/Clojuratica · GitHub This makes me wonder if there are still things that can be invented to work with Clojure! Also the Mathematica integration! If you are a Mathematica user but would like to code in it using your favourite language, this project is for you. Although I’m not sure is actually maintained anymore, it might make a good use case to revive it to bridge the Wolfram language instead.

Clojure Categorized Nice list of standard library categorized in a different way than the main website proposes. Is not up to date. I’m linking it here just in case one day I want to update it with the current stdlib fns. I can see a lot I never used or knew about.

What is Clojure-in-Clojure? Amazed how far “modern” Clojure efforts like Clojure in Clojure can be tracked back in time. Clojure in Clojure was on of the focus after release 1.0. For that to happen, Rich envisioned the need for a “newnew” something sitting on top of lower level gen-class that made it easier to port the Java side of clojure. “newnew” then became deftype/defrecord and protocols later that year. One critical design decision was to not support what in Java is supported with abstract classes (but there is definterface just fine and some other trick to get around it). Wonder if this is was determined that Clojure in Clojure is not happening as a straight Java port but more as a rewrite these days.

Comments (View)
October 2, 2014

Clojure Weekly, Oct 2nd, 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!

sicp-mailonline - Google Groups Announcing a new SICP study group starting next week in London. I organised another one a couple years ago and only managed to the to the 3rd chapter. This time I’d like to work on it with Clojure, my favourite language. If you’re London based or you have friends in the area feel free to attend and spread the word.

Clojure Google Summer of Code Results Here’s a summary of the achievements for the Clojure projects during this Google Summer of Code. There have been three main focuses: performance improvements, typed clojure and extensions to core.matrix. Exciting results in the field of the Clojure compiler performances with Skummet and Oxcart testing ideas for different compilation profiles. Nicola Mometto extended his analyser to work for Clojurescript too. There are many other interesting projects to have a look at on the same post.

A Review of The Art of the Metaobject Protocol (PDF) You might have heard of the Art of the Metaobject Protocol, a book that describes the internals of CLOS, the Common Lisp Object System. The linked pdf is an essay written by Richard P. Gabriel about the context behind the book, some history of CLOS and a summary of the content. MOP is the inner-most layer of CLOS, where the way inheritance, extensibility and polymorphism behave are exposed as an API for you to extend. CLOS is both reflective and introspective. It is reflective in the sense that is defined in itself and introspective in the sense that it defines what is a class, a descendant of a class, a slot container and so on. It provides hooks to alter this semantic allowing the user to create a different OO system all together. Interesting final note: the authors of Scheme were creating new interpreters to understand OO arriving at the end at the conclusion that function calling is the same as message passing. Here we go, the grand unification theory of FP and OO!

Alan Kay at OOPSLA 1997 - The computer revolution hasnt happened yet - YouTube This Alan Kay’s keynote enters my top 5 straight away with possibly the highest concentration of wisdom per slide. I can give you an overview here, but there is nothing more I can do, just go watch it now! My main takeaways are: OOP was intended as a paradigm to grow systems to unbelievable scale, the same of cells in a living organisms. It was misinterpreted in many ways, starting from C++ (many vitriolic comments) ending to Java without a decent meta-reflective system. In Kay’s view, the number “3” could be implemented as a process with an IP and URL. But we can’t manage that kind of scale. Our system are so complicated because we think small. Good words about Lisp CLOS and page 14 of the 1962 programmers manual by McCarthy, for its half a page description of the Lisp meta-reflective capabilities in Lisp itself. Much more.

Get going with core.async: Get going with core.async Brand new core-async reference out there. Apart from a nice step by step tutorial (there are many around) the best part I think are the /reference/apidocs and /reference/primitives. The API reference is way better and readable than the standard one. The primitives section contains an interactive channel demo, a very nice learning tool.

Coverage · strangeloop/StrangeLoop2014 Wiki The official coverage page from StrangeLoop staff collects all the buzz surrounding the conference. Notably: the scripts of some of the talk to read are a useful addition, plus all blogging around the conference. Apparently I missed a great conference this year!

Comments (View)
September 24, 2014

Clojure Weekly, Sept 24th, 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!

Diversity of Approach (David Nolen) Almost half of this podcast is dedicated to re-iterate on an important concept inside Om: fast diffing of nested data structures. Why it works is simple, but maybe David never tells the basic fact about what it means to be an immutable data structure in memory (after all). It means that the head pointer of that data structure (or any of its sub-branches) is always the same and never changes. So if the language allows for some sort of view of into memory addresses (like Java does printing an instance with Object.toString()) if you change an element of a vector you get back another head pointer (and the previous is the same). Now, pointers aren’t really transparent in Java or JavaScript, but this is conceptually what happens. So how long it takes to know if two immutable data structures are the same? Just compare the head pointers, which in Java is the double == operator. With this fast equality, application that requires intensive mutation on an in-memory data structure (the DOM for example) have a way to be really fast.

Thinking Outside the Loop (Chris Granger) I like Chris Granger (of LightTable fame). He’s got big ideas and he delivers them. In this podcast Chris explains the path that brought him from user interaction testing at Microsoft, to LightTable live-coding environment, to experimenting with Aurora prototype down to the new startup is that is soon to be launched. The problem he’s trying to solve is how to have what we usually call business analysts to be able to code without being actually programmers. Is that even possible? Well, think about Excel. The future is declarative and visual and this is what Chris is working on, a new visual language that evolves Excel into a real programming environment. Inspiring. In the show notes, the link to the paper that inspired him in this new challenge.

"Inside the Wolfram Language" by Stephen Wolfram - YouTube Another interesting talk from StrangeLoop this year. What Stephen Wolfram is showing us with his language is frankly mind blowing. It’s not about the language itself I think (which resembles a Lisp on square brackets), but more about the IDE and the environment it works in. It can apparently represent anything, from image to sounds, internet to pdf reports, deploy to the cloud or iphone, generate other languages or REST Apis. An interesting question would probably be what it cannot do. It is certainly inspiring as a live programming environment (like LightTable on steroids) and as a all-around scratch pad for anything research oriented. As of real-world every-day programming I don’t think so. It seems to be closed-source, closed-world that you are going to lock yourself in.

"Transducers" by Rich Hickey - YouTube Another great talk by Rich from Strange Loop 2014 conference. Transducers implement an elegant functional abstraction that enables “packaging” of data transformation logic that can be re-used. Personally I don’t perceive them as revolutionary or ground-breaking though. I would like to see Reducers to be retrofitted to make good use of transducers chains (if that is not possible already) so the two features (transducers and reducers) can effectively be seen as part of a consistent design.

Clojure Tutorials - with Tim Baldridge Highly instructive series of screencasts from Tim Baldridge of core.async (and much more) fame. He keeps them coming at an amazing speed, 2/3 per week of about 10-15 mins each and considering the 4$/monthly it is a steal. The quality is also very good. I watched a couple of them and I’ve been impressed. There is also an option to access them on dropbox as mp4 that makes them very handy on troubled connections.

Om Bootstrap Interesting port of Bootstrap into ClojureScript Om already in a reasonable working state. Expanding a little bit on the concept, it means to translate the JavaScript part of Bootstrap into ClojureScript and migrate those components to Om including all the reactive goodness. What impact it can have on Bootstrap itself as a normal user is hard to say, but it is probably important if you want to interact or extend with the Bootstrap components from within your application.

Comments (View)
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.

Amazon.com: 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 http://www.purelyfunctional.tv, 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.data/diff - Clojure Documentation For the unknown pearls in the standard library, this week I’d like to introduce you to clojure.data/diff. 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)