I don’t like Clojure destructuring putting map keys after the vars to bind them to. There must’ve been some really compelling reason to do it this way, but oh god, it’s extremely broken and unjustifiable to me.

JS got it right.

@aartaka sorry, but would you have time to share an example what you don't like in clojure destructing Syntax for maps?

@muhanga @aartaka Presumably referring to this:

(let [{resp-body :body} {:status 200 :body "Hello World"}]
resp-body) ; => "Hello World"

I imagine it feels odd because the (binding) key / val are reversed from the data being bound. (`[{a :a} {:a 1}]`).

Not entirely obvious to me that that *couldn't* have been done in the other order. OTOH, it does feel natural to keep the bound names to the left in a binding form.

@muhanga @aartaka I'd guess another factor in the design decision is the special keys like :as, :keys, :or, etc. which are somewhat analogous to keyword arguments, and thus would naturally live to the left of their values.

If keys to be destructured also went on the left then you could get collisions with those names.

@camdez @aartaka
Yeah, ouch, my brain really did not like this, so I can fully understand not liking this.
And this is why I removed knowledge from my head about this de-structuring pattern even existing in the clojure.

Most of the time the `{:keys [body]} m` de-structuring should work for me, when it don't I would say I am doing something clearly beyond my level of comprehension and I should probably stop.

@muhanga @camdez one case where :keys are clumsy is destructuring of XML maos with their shouting CamEl CaSe. Hyohenated var names are much more natural. But, alas, the syntax is suboptimal.
@aartaka @camdez And now I remember parsing XML also. I remember that I had to make myself a separate dictionary to make translation from Camel to clojure keys... and then I was very brutally wounded when I found that some tags were namespaced and I had to handle ":" in keys name.

@aartaka @muhanga Weird string keys are definitely annoying… once you’ve gone down the keyword route, you sure wish everyone else had too.

The destructuring syntax honestly doesn’t bother me anymore (after years of using it, to be fair), though it does get hard to read with a lot of nesting, and I occasionally battle with myself about how I want to indent it (being a person who usually likes to align keys across lines).

@camdez yeah, we have an unspoken policy in out team to align keys when destructuring. Better than nothing, but worse than leading keys, I think.

@muhanga