r/Clojure • • Oct 19 '26

In Context - Rich Hickey (Clojure/Conj 2026)

https://www.youtube.com/watch?v=P5eO7BNyJao
140 Upvotes

18 comments sorted by

19

u/joe_Mayaa Oct 19 '26

Gotta stop all my work and watch this first.

8

u/geokon Oct 19 '26 edited Oct 20 '26

Great talk - rather simple and straightforward stuff

This enhanced destructing is now unashamedly explicitly specifying the map shape and also doing binding in one pass - which is great and it looks ergonomic. The syntax could be prettier, directives have always been a bit ugly, but it's very usable and doesn't break existing code. But is there a way to inspect the implicitly specified map structure?

A kind of tangential-but-similar thing is the EQL spec - which has a very different syntax, it's very concise and only specifies the shape without doing any binding. I'm a bit unsure if EQL is also coming from the core team, but I'd love to know what they think of it in contrast to destructuring.

In my case I'm thinking in particular about Pathom where the defresolver macro forces you to do bindings and to then redundantly specify the shape of the input and output. Looking at this extended destructuring, it seems like the prime place for something like this to bring it all together in to one thing. For nested inputs/outputs the current Pathom setup gets very verbose and errorprone b/c you have to keep destructuring and the shape EQL specification in sync.

Just an example I pulled from my code - it unpacks some columns from a tmd table:

(pco/defresolver $daily-rain
[{::keys [window-size
          bin-size
          data]}]
{::pco/input  [::window-size
               ::bin-size
               {::data [{:Days-from-start [:data|]}
                        {:Rain-mm [:data|]}
                        {:Year-Decimal [:data|]}]}]
 ::pco/output [{::daily-rain [{:x [:data|]}
                              {:y [:data|]}
                              :window-size
                              :bin-size
                              :meta|]}]}
{::daily-rain {:x     (:Days-from-start data)
               :y     (:Rain-mm data)
               :window-size window-size
               :bin-size bin-size
               :meta| (mapv #(hash-map :Year-Decimal
                                        %)
                              (:data| (:Year-Decimal data)))}})

(Actually the defresolver macro does try to auto-infer the input shape, but it's rather weak and can only infer top level keys from the destructuring)

Clearly it'd be ideal to specify what you want using enhanced destructuring, and to then have the shape inferred by the Pathom engine (though for the output maybe you'd still be stuck to using EQL?)

Overall what's presented I think is a very interesting, but it feels like this could use more hammocking and could be pushed further. For instance if I want to just specify an interface with not binding - a la EQL - using this destructuring syntax the current interface seems to allow for that but it'd be a bit ugly right? And some stuff wouldn't be possible Ex: these & :a :b .. "additional keys" are cool, but they only work inside of the :keys directive it seems? Is there even a way to specify a non-bound deep/nested shape?

I'm not a Clojure guru, and I haven't considered the breadth of potential use-cases - it's more of a "gut feeling" - so I'd be curious to hear if I'm offbase here

PS:

EQL is a bit weirder b/c nested maps can be maps or a seqs of maps. The syntax is ambiguous (there's probably a good reason for that, I'm not an expert in GraphQL stuff)

An EQL specifying

[{:user [:name
         {:address [:street
                    :zip]}]}]

matches both

{:user {:name "Bob"
        :address [:zip 94115]}}

{:user [{:name "Bob"
        :address [:zip 94115]}
        {:name "Bill"
        :address [:zip 94114]}]}

So that doesn't quite map to the destructuring scenario - as the EQL is a bit under-specified and covers more cases.

PPS: At the end there's a mention of a deep-merge, finally :)

6

u/chladni Oct 19 '26

Looking forward to watching it. I must have picked up that this was about to drop, had a dream I was watching an episode of Columbo where Rich Hickey was the guest culprit.

2

u/joinr Oct 20 '26

How did he slip up and get caught?

11

u/devourer-of-beignets Oct 20 '26

Type error

1

u/emaphis Oct 22 '26

Ah... One more thing, sir.

1

u/WrinklyTidbits Oct 22 '26

added static types to Clojure

9

u/josephjnk Oct 19 '26 edited Oct 19 '26

I love Rich and the vast majority of his talks, but I found “Maybe Not” hard to sit through. It felt more like partisan mud slinging than a deep discussion. Is this one better?

EDIT: for anyone else who had this worry, watch it, it is much better. He still has some strong opinions about paradigm war topics that I don’t agree with, and he harps on them a fair bit, but this gave me a lot to chew on even as someone who hasn’t used Clojure in years.

11

u/Spiritual-Slice-6150 Oct 19 '26

watch it?

1

u/josephjnk Oct 19 '26

Fair, already started.

1

u/angrynoah Oct 20 '26

Torn on whether to watch this. I always loved Rich's talks but I've left software and I'm trying to forget this stuff.

1

u/Save-Lisp Oct 21 '26

Thanks for the talk!

1

u/gzmask Oct 22 '26

I like it. Reminds me of the Elements of Clojure book by Zachary Tellman. One of those books that changed my view in programming forever. The main idea is that "to be extremely frugal on introducing new names into your context". That idea ages so well with our now token driven programming era.
I might be less in agreement with the static typing thing. But any language design that reduces the names one having to hold in their heads, gets my vote.

1

u/Savo4ka Oct 24 '26

I'm wondering how compatible this new syntax will be with clojure spec?

1

u/seancorfield Oct 24 '26

Can you explain what you mean / what your concern is?

We use Spec heavily at work (and have done for over seven years) and we're using the 1.13 syntax in a bunch of places too. No conflicts.

2

u/Savo4ka Oct 24 '26

Sorry have not written Clojure for a long time. Maybe its stupid question. From the talk I understood the new directives mostly being for map keys not the keys content.

How would more full example look like with required keys validation together with spec?

Edit: Isnt there some duplication to what spec provides and these new directives?

2

u/seancorfield Oct 24 '26

Spec talks about the values of keys, the new destructuring talks about the presence of keys.

This mirrors what was being considered in Spec 2, with schemas and selections (and Spec 2 is now officially dead).

For qualified keys, in particular, we can look to RDF where we have attributes and values, and then the destructuring provides specific collections of attributes. You can then use (s/valid? (s/keys) select-map) and you'll get validation of all the keys' values from :select select-map, for example, because Spec checks all keys in a map for matching Specs.

Defining aggregates in Spec, where s/keys listed the required and optional keys, was always "static" and didn't compose well in nested data structures. In real world programs, we often need different aggregations, but Spec has no good way to do that (without an explosion of static s/keys aggregates).

Now we have a way to describe a required and optional set of keys, deeply, at the point of use, and then use Spec to describe the values for those unique keys. "Design is taking things apart", as Rich often says.

One thing we don't have (yet?), is a way to describe that validation at the point of use for unqualified key-based maps (but perhaps this will continue to encourage more use of qualified keys).

1

u/Savo4ka Oct 24 '26

Thanks for clarifying