Fork me on GitHub

Hi there. I have a silly question: can you rebind a destructured key from a map? For example, if I have a small piece of code like this

(fn [{:user/keys [username password] :as user}] ...)
Is there currently any way to rebind username to something else, say, like user-name? Of course a common way would be to use something like
(fn [{user-name :user/username}] ...)
I'm just curious if there's another way to work with keys instead. Thanks in advance 🙂


:keys destructuring is a shorthand. (let [{foo :some-key} {:some-key 3}] foo)


user=> (let [{:user/keys [password] user-name :user/username} {:user/password "pass"
                                                               :user/username "user"}]
         [password user-name])
["pass" "user"]


I see. So it's not possible with keys then. Thanks a lot 😄


Hi I m relatively new to programming (learnt basics of programming but no production experience) . Any suggestion for a good clojure book for beginners like me? Is there a good structure course for beginners, paid or otherwise? I am asking because all the resources I have seen so far are aimed at experience d programmers (those proficient in at least one programming language).


Clojure for the brave and true is free - I started with the video courses of - > courses has since been moved to


Thank you.


I recommend just flooding yourself with Clojure material a little. Read Brave & True, it's great. Watch random videos that sound interesting, like Eric's mentioned above. Don't worry about remembering everything, you'll get the hang of things. Make little scripts or games or other stuff that sounds interesting. Then return to the books and videos.


I haven't read it myself, but I've heard many recommendations for Getting Clojure.


Also another recommendation for after you know the syntax of clojure- FredOverflows videos on Advent of code 2020 really helped me in solving problems in clojure - - They get harder very quickly, but try to solve them first yourself and then see how fred does. His explainations are very good,

dgb2309:03:40 check this out! its playful and well made


Thank you for the suggestions. Hope this one is also not too advanced to go through


as building a tutoring type app is one of my medium term goal


this is a friendly/good book but there is a gap between “programming basics” and “full-stack web development”. On the other hand there is no shame in just trying for a while and then continuing after filling in some gaps. That has been my approach with some books and topics too.

☝️ 1

I see. Then I will go through the fundamentals with True and Brave (or Getting Clojure, Programming Clojure), then do Koans (or exercism), and then the web dev book. Let me know if you think this is reasonable. Thanks


Clojure for the Brave and True assumes you're working in emacs. If you prefer a different editor/IDE, keep using that, ignore the emacs parts of the book and focus on learning Clojure. If you haven't decided on an editor/IDE, I think VSCode w/ Calva is the most beginner-friendly nowadays. > Let me know if you think this is reasonable. Sounds good to me!

👍 2

Thank! Btw, I am using Cursive.

👍 1

The Clojure Workshop. Surprised that no one didn’t mention it


About what @U01EFUL1A8M said: there's definitely both "programming itself" vs. "using all the frameworks that people use e.g. for web development" and in my experience you need both. So nothing wrong with learning both at the same time, as long as you realize they're different but related topics 🙂 When I was doing Ruby on Rails, tons of people only knew Rails (the web framework) but barely any Ruby (the language). Avoid that 😉

Roee Mazor09:03:32

Hi hi, What should be my goto solution when needing to compress and uncompress some json / map?

Ferdinand Beyer09:03:31

Not sure if there is a “pretty” clojure lib out there (I guess there is). I would start looking into what the Java standard library offers, namely GZIPInputStream / GZIPOutputStream:

Roee Mazor09:03:29

yeah, I saw this example: was afraid thats the best solution 🙂

Roee Mazor09:03:02

Ill try that lib, thx!

Ferdinand Beyer09:03:41

> was afraid thats the best solution Don’t be afraid of some Java interop 🙂

Roee Mazor13:03:34

haha, maybe after this I won’t 🙂 thanks a lot!

👍 1
Ben Sless14:03:07

Interop with gzip input stream isn't terrible. All serialization libraries can probably handle input streams so you just need to wrap the zipped stream with a gzipinputstream and pass it along to the deserializer. If this is in a web server, best do it in a middleware

Danilo Oliveira14:03:04

What is the most "clojuronic" way of handling errors on user inputs/actions? java.lang.RuntimeException? I did some research and did not found too much stuff about monadic errors (like Scala/Rust) and usage of tuples (Like Go). Should I just throw errors in such cases?

Ferdinand Beyer14:03:58

I think exceptions are actually most common. Clojure does not tend to define its own types thow, but you will often see (ex-info) exceptions to be thrown, carrying data in a map. There are libraries to all kinds of styles out there, e.g. failjure, exposing a monadic style


In my current client we have gone back and forth on exceptions vs more monadic error handling several times. We've found trying to handle monadic error values to be 'swimming upstream' and are now refactoring to remove these various experiments in favour of throwing exceptions. Using anything else just rubs up against friction with other libraries in the Clojure space or imposes an excessive overhead in having to cope with error values all the way up the function stack on return.

Cora (she/her)14:03:02

I've definitely used tuples

Cora (she/her)14:03:33

but what to use probably depends on the interface and what I want to display to the user


Is there a (easy) way to convert Bigints to hex string? This doesn't work:

(format "%x" 1N)
java.util.IllegalFormatConversionException: x != clojure.lang.BigInt [at <repl>:10:1]

(format "%x" 0xffffffff92492493)
java.util.IllegalFormatConversionException: x != clojure.lang.BigInt [at <repl>:10:1]


user=> (.toString (biginteger Integer/MAX_VALUE) 16)

👍 1