Fork me on GitHub

Just out of curiosity, Why does Rich Hickey not do any Clojure related talks anymore? I know he did a history of Clojure video in 2021 (I think). But apart from that, there's silence. I really enjoyed his presentations

Alex Miller (Clojure team)03:10:58

Because they鈥檙e really time consuming

馃憤 1

As someone who used to do a lot of conference talks around the world for about a decade, I can totally support that! I think most people (who haven't given conference talks) have no idea just how much work goes into them -- and also how it can kind of "spoil" the conference for you, until you've given your talk (so an end-of-conference keynote is, in many ways, much worse than a regular talk during the conference).


I stopped speaking at conferences in 2013 and I have really enjoyed attending conferences since then! 馃檪


(although I keep promising myself I'll submit a talk to Conj one year!)

Lennart Buit06:10:18

Please do Sean! I, for one, would be interested :)


@UC1DTFY1G what talks would you want Rich Hickey to actually give? I still get value revisiting many of the videos Rich has done over the years and its not immediately obvious to me what new topics would be beneficial. As others have stated, preparing a talk can take many days or many weeks to prepare. The live broadcasts on Clojure I did for an hour each week for Practicalli would take the whole week to prepare and most would have benefited from more preparation. Personally, I would rather Rich focused on stewarding Clojure itself, especially as more and more of the Clojure community are sharing their experiences.

馃憤 1

@U05254DQM Nothing specific. Sends out a good message if the creator of the language makes a public appearance once in a while. That's all. Some people actually ARE sheep who'd rather follow someone 馃槃 (myself included sometime) For those who lack the skills to practically grok everything by themselves, it's a good heuristic to follow others who are respected. (This is true no matter how much I dislike this fact)


There are many people in Cognitect (now NuBank) who regularly give talks, as well as a hugely diverse community. I think its highly dubious for one person to be seen as the only respected source for a language and personally this would be one thing that deters me from that language. Clojure is an established language and used by those who appreciate its qualities and spend time investing in it. I think the software industry would be much more mature if everyone had the opportunity to meaningfully consider the language(s) they use.

馃憤 1

How useful do you find visualization tools like portal or reveal?

Ben Sless06:10:12

As useful as taps are, which is very


For me, Portal is a core part of my workflow. I use VS Code/Calva with the Portal extension (so it runs inside VS Code) and I have my actual REPL hidden and rely entirely on Portal. The ability to use datafy/`nav` on complex data structures as well as multiple ways to visualize that data is immensely powerful.


I really need to do some screencasts of how I work since it's a lot easier to show than to tell...

馃憤 4

Even the most basic aspect: showing hash maps and vectors as tables is a huge comprehensibility boost over plain text in a REPL.


@U04V70XH6 One of the most difficult parts of learning Clojure for me has been getting the correct dev setup. I think the REPL workflow and integrating tools like these should be front and center. Instead I found out these stuff slowly. Anyway, please do a screencast. That'd really help me and I guess many others.


It doesn't help that I'm stuck on Windows either


Clojure seems unaware that Windows exists


@U04V70XH6 One question. I need to tap> something to send it to portal right? If I just Ctrl+Enter in calva, that form gets sent to repl and evaled. Is it possible to have this kind of setup with portal without explicitly adding tap>s all over the code?


I do all my dev on Windows -- both at work and for my OSS projects (two separate machines). I use WSL2 for all the Clojure stuff and run VS Code on Windows.


@U04V70XH6 Yeah, I realized I need WSL2 way too late 馃槃


My repo has my VS Code / Calva / Joyride / Portal setup, for the most part, and my repo has my aliases and my dev.clj which starts my REPL (and patches if Portal is on the classpath).


I use the Portal middleware for nREPL so all my evals are tap>'d and sent to Portal, although I have some customization around that so evaluations that invoke tap> directly are handled differently. My Calva customREPLCommandSnippet settings are in my vscode repo in an EDN file and that's where all my tap>-related magic happens.


I use Joyride to open VS Code's Simple Browser with or Java Docs as needed -- so I don't have to switch to a browser. I use Portal for all my REPL output -- and keep Calva's nREPL output window hidden (I never type into a REPL).


(midnight here so bed time -- happy to discuss in depth tomorrow or another day)

馃憤 1

@U04V70XH6 ok, I will go through and try to make sense


Having to manually tap> is what keeps putting me off


Thanks, I will have a look and bother you in case I can't make it work I guess 馃槀


Is there a way to attach metadata to something in such a way that it shows up automatically in some variation of print? (Preferably with at least some resistance to losing that metadata during common transformations.) i.e. something like

(defn Foo [x] ... make x self-descriptive as a Foo ...)
(let [foo (Foo "foo")]
  (prn foo))
=> Foo <"foo">
=> nil


Do you mean via

(with-meta {:foo :bar} {:kind :Foo})
=> {:foo :bar}

(meta (with-meta {:foo :bar} {:kind :Foo}))
=> {:kind :Foo}
You can always write a custom prn function that also prints out the meta. Otherwise it depends on your dev env - eg. Portal visually indicates that certain data has metadata attached to it.


Or do you mean more along the lines of creating a defrecord and overwriting the default print-methods?

(defrecord Foo [bar]
  (toString ^String [this] (my-custom-string this)))

(defmethod print-method Foo
  [this ^Writer w]
  (.write w (my-custom-string this)))

(.addMethod pprint/simple-dispatch Foo
  (fn [this] (print-method this *out*)))


Not sure what I mean, as far as what the language actually offers. I just have some things that are kind of like types, and would like for the info that "this is a thing" to present itself on introspection, even though I'm not looking for any sort of type enforcement.


Sounds like you probably want to use Check out e.g. "Applying Viewers" in to see how Clerk uses metadata notation to pass around and react on type information, without interfering with the original value.


And I just realized, Clojure even has built-in *print-meta* :


Thank you. I was already aware of the existence of metadata. The problem (ignoring that it cannot augment simple values ...

(def foo ^:Foo "foo") ;; Syntax error
(def foo ^:Foo 123) ;; Syntax error
... ) is that it does not present itself organically in any way.
> (def foo ^:Foo ["foo"])
> (prn foo)
You have to go out of your way to ask for it.
> (prn (meta foo))
{:Foo true}


Or maybe I just need some trick to get Calva (or nrepl or clojure-lsp) to surface metadata?


Have you tried:

(set! *print-meta* true)


it changes the global state of your runtime, so it would be better to hook into the nrepl printer and just modify it via binding - but this should start printing metadata for all your repl interactions


Interesting idea. I wonder how much noise that will add from other things.


I don't think I realized you could set that globally.


it's a dynamic variable, which is why it uses the asterisk naming convention *_name_* - it's because theoretically, it can be modified at any time; Usually you don't want to modify it globally without scoping it via binding if you can help it :)


You can read more about dynamic vars here:


But if setting the *print-meta* gives you the desired results, I would encourage you to dig further and see how Calva is printing the repl results, because hopefully you can just hook in and modify that behavior locally with binding vs changing it globally for your entire runtime. Perhaps ask on #CBE668G4R?


Seems like the best answer is probably just to define types. The simplest example would be a record for what would otherwise be map data, since that comes with tagged map-like printing already built in.

(defrecord Foo [foo])
(->Foo "foo")
; => #my-ns.Foo{:foo "foo"}

Lior Neria08:10:07

Hi 馃憢, I need to implement a function that iteratively goes through all the folders that are under resources and reads all the json files that are in each subfolder and unites them into one file - so that each subfolder will have one json file. I was able to implement the function in the meantime only with a reference to the specific path and to combine two Json files only. Is anyone knows how I can run iteratively on all the subfolders? Thank you :)


You need to go through all the files in the folder, and map json/read-value and merge everything later I guess:

  (map #(json/read-value (slurp %))
See here on how to get all files in folder: If you need to output the merged json to a file, you can do that afterwards.

馃憤 1
Martin P暖da09:10:31


(defn merge-jsons
  "file should be, eg (File. string-path)"
  (let [all-files (.listFiles file)
        subfolders (filter #(.isDirectory %) all-files)
        subfiles (filter #(.isFile %) all-files)]
    (->> subfiles
         (map #(json/read-value (slurp %)))
    (doseq [f subfolders]
      (merge-jsons f))))
file-seq and .listFiles have different results (`file-seq` returns all files, .listFiles only these on the current "level").

馃憤 1
Martin P暖da09:10:22

And you have to spit somewhere the result of json/write-value-as-bytes.


How do I do nested desctructurings? Example:

(let [{:keys [tag content]}
      {:tag :seriesKey :content ["2372"]}]
  [tag content])
[:seriesKey ["2372"]]

;; Now if I wanted to "unroll" the :content, 

(let [{:keys [tag [content]]}
      {:tag :seriesKey :content ["2372"]}]
  [tag content])
{:keys [tag [content]]} - failed: simple-symbol? at:....
{:keys [tag [content]]} - failed: vector? at:....
Is there a way to do such "nested" destructuring?


(let [{:keys [tag]
       [content] :content}
      {:tag :seriesKey :content ["2372"]}]
  [tag content])
try this

馃憤 1

@U04V4KLKC wow, great. Is that syntax for "naming" keys?


I don鈥檛 know if there is a name for this because this is the most basic destructuring primitive for maps 馃檪 Here is a complete guide for various destructuring options available in clojure. -

馃憤 1

You can check the official docs here for some examples too!

馃憤 1

Hello, when building an uberjar from my pedestal app, logging to file does not work anymore. 鈥 It works, when I start my project from the repl. 鈥 The pedestal samples work, differences to my project are 鈼 I created my project with deps-new and use the given tool chain Is there something obvious I'm missing? Did anyone run into the same issue?


adding the path of the logback config file as jvm argument, solves the problem java -Dlogback.configurationFile=file:path -jar ...


jo is there a function with the semantic (first (filter pred coll)) some returns the return value of pred, but I want to "find" the first element for which pred is true

delaguardo09:10:11 there are some idioms you might copy to ypur project but non of them got landed in clojure core yet


cool thanks

Jing Guo09:10:29

I鈥檓 really new to front-end development, but am thinking about developing a web app recently. People seem to suggest regent, which is based on React. Is this the 鈥渟implest鈥 approach for someone new but wants a nice UI? Or I miss something鈥


Reagent is probably a good place to start. You can use #C034FQN490E to develop instantly. Example website:

Jing Guo10:10:26

@U02CV2P4J6S thank you. Will check it out. I don鈥檛 want to use any frameworks so I鈥檓 trying to figure out these things myself.

Benjamin10:10:10 this is a great walkthrough using only vanilla cljs (js interop) irrc

鉂わ笍 1

Depending on how text-heavy your pages are 鈥 if for example, you're building mostly static HTML with some interactivity tacked on that needs to talk to a backend 鈥 then you might want to give HTMX/ctmx some consideration. My understanding is that they offer interactivity without the overhead of JS and react, instead delegating the computation for interactivity to the backend. May not be appropriate if you want to create highly interactive front end content that doesn't require a backend component.


"Nice UI" in this context would be achieved using CSS rather than react; something like TailwindCSS could help you get something nice and customizable quickly. But it's very much a framework, so you may prefer to just use your own CSS instead.


Reagent is pretty simple, essentially you write hiccup or selmer & html templates for the content and reagent manages the virtual DOM (updates the page efficiently) I use Bulma CSS library to add some nice styling. You can use a Clojure atom to manage state changes and if the component used data from the state, reagent manages the updates when that data changes. A very simple example: This is the development workflow I take

Jing Guo11:11:50

Thank you, @U05254DQM I found your website really useful.

Jing Guo11:11:51

@UFTRLDZEW thank you for your advice. I don鈥檛 want to use Clojure framework, but I think CSS frameworks should be fine, if they do not introduce too much overheads. I think JS or Clojurescript seems to be 鈥渟low鈥 whereas CSS seems to be fast? My personal website is static only, so not sure about the other side. EDIT: can I use garden library with tailwind?

Abhi Saxena15:10:09

Hi All, I just realized a strange behavior in Java API, where it rounds off the date as "2023-02-30" (Feb 30) to "2023-02-28T00:00:00Z"

(defn str-to-date [date-str]
  (LocalDate/parse date-str
                     (doto (DateTimeFormatterBuilder.) (.parseStrict)
                       (.appendOptional (DateTimeFormatter/ofPattern date-format-dd-MMM-yyyy))
                       (.appendOptional (DateTimeFormatter/ofPattern date-format-yyyy-MM-dd))))))
Is there a way to enforce Lenient and let it fail if this sort of input is provided.

Abhi Saxena17:10:47

Sure, let me try that out


I use clojure.xml to parse xml (data from many services): (xml/parse (.ByteArrayInputStream. (getBytes xmlstr))) I hit a snag with one xml though:

;Error printing return value (MalformedByteSequenceException) at (
;Invalid byte 2 of 3-byte UTF-8 sequence.
What can I do here? Probably there's something wrong with the data but I don't control it. Is there a way to somehow ignore this singular error and continue as if nothing happened? 馃槃 Or to sanitize data?


NVM, (xml/parse (.ByteArrayInputStream. (getBytes xmlstr "UTF-8"))) works 馃槃

Ben Lieberman18:10:48

If I have a lazy seq of fn's, say as a result of repeatedly, what's the best way to apply those fn's to values? I've tried variations of using map and apply with no luck


Sounds like you want reduce


There are at least some ways that map and apply could be used to apply functions in a sequence to values. For example:

user=> (def fn-lst [inc dec #(+ 3 %)])
user=> (map (fn [f] (f 2)) fn-lst)
(3 1 5)


And continuing that example for a variation:

user=> (map (fn [f v] (f v)) fn-lst [10 20 30])
(11 19 33)

Ben Lieberman18:10:13

This is a trivial example while I try to figure this but

(map (fn [x] (x 7)) (repeatedly rand-int))
this throws an ArityException


rand-int needs an arg


Here is something that might be what you are looking for?

user=> (map (fn [x] (x 7)) (take 20 (repeat rand-int)))
(2 5 4 0 6 6 1 4 2 0 6 1 1 2 0 4 1 1 6 4)

馃憤 1

Note repeat instead of repeatedly, which do very different things


@U0CMVHBL2 Is it better to "lift" the (take 20 to outside?

Ben Lieberman18:10:31

I am curious why repeatedly does not work here?

Ben Lieberman18:10:00

I use repeat all the time but to make seqs of things that are not functions


Takes a function of no args, presumably with side effects, and
returns an infinite (or length n if supplied) lazy sequence of calls
to it


I think it depends what you want -- my only purpose was to make a small example with small output 馃檪

馃憤 1
Ben Lieberman18:10:24

So does this

(take 5 (repeatedly #(rand-int 11)))
meet the "no args" criterion bc rand-int is inside an anonymous function?

Ben Lieberman18:10:58

(That's from clojuredocs)


In that example, rand-int is called with exactly 1 argument, the integer 11


#(rand-int 11) is an anonymous function that takes no arguments.

Ben Lieberman18:10:19

That's good to know, I did not know you could use anonymous functions like that