A mistake that shows up at least once in almost every class I teach.
The Clojure reader macro #()
creates an anonymous function whose body is a single expression, and that expression must be a list.
Digital Digressions by Stuart Sierra
From programming to everything else
A mistake that shows up at least once in almost every class I teach.
The Clojure reader macro #()
creates an anonymous function whose body is a single expression, and that expression must be a list.
I’m five episodes in, so I think it is safe to announce that I have a podcast!
No Manifestos is a podcast about people living with technology, because that describes everyone today. Whether you work in the sciences, business, or the software industry itself, everyone has to use and live with software.
Continue reading →I’ve spent time at various jobs “pairing” with another developer in a different location.
Sometimes I think I must have tried every different piece of software ever developed for this purpose. I have not been completely satisfied with any of them.
Continue reading →A brief addendum to my last post about Clojure’s threading macros.
I said you could use as->
to work around the placement of an argument that doesn’t quite fit into a larger pattern of ->
. My example was:
(-> results :matches (as-> matches (filter winning-match? matches)) (nth 3) :scores (get "total_points"))
This is not a good example, because filter
is a lazy sequence function that should more properly be used with ->>
. And I warned explicitly against mixing ->
and ->>
.
Here’s a better example.
No, not multi-threading. I’m talking about Clojure’s threading macros, better known as “the arrows.”
The ->
(“thread-first”) and ->>
(“thread-last”) macros are small but significant innovations in Clojure’s Lisp-like syntax. They support a functional style of programming with return values and make composition intuitive. They answer the two chief complaints about Lisp syntax: too many parentheses and “unnatural” ordering.
A couple of weeks ago, I sat down with my new coworkers Camille Acey and Paul Groudas to talk about the work we’re doing to scale up and expand Clubhouse.io.
The interview is on the Clubhouse blog as Building for Growth: A Conversation with Clubhouse’s Paul Groudas and Stuart Sierra.
How long does Clojure start-up really take? Let’s find out.
Polymorphism is a powerful feature. The purpose of polymorphism is to provide a single, consistent interface to a caller. There may be multiple ways to carry out that behavior, but the caller doesn’t need to know that. When you call a polymorphic function, you remain blissfully ignorant of (and therefore decoupled from) which method will actually run.
Don’t use polymorphism where it doesn’t exist.
All too often, I see protocols or multimethods used in cases where the caller does know which method is going to be called; where it is completely, 100% unambiguous, at every call site, which method will run.
Earlier this year, I wrote a piece for the Cognitect blog:
Developing the Language of the Domain (blog.cognitect.com)
In it, I describe the process of building a domain-driven application using Clojure, ClojureScript, EDN, Datomic, clojure.spec, Pedestal, and Om.
Quick link: Stuart’s ns Style Guide
Everyone has their own personal quirks when it comes to syntax. No matter how hard you try to lock it down with code review, IDEs, scripts, or check-in hooks, individual differences will emerge.
Continue reading →