Fork me on GitHub

Anyone remember where this is? I saw about a month ago a talk on clojure code management where the guy never put code into files, instead placing it in a database. I'm afraid I can't be more specific since it's been too long 😜

😂 3

Datomic as source control? thinking-face


I am wondering on usage of memoization/ttl. My question regarding is: if the cache is invalidated and memoized function get called several times in mutlithreaded env how will it behave? Will there be one computation for the first cache miss and waiting on result from subsequent invocations or will all pending invocations go compute the value? I am thinking if background tasks that are basically "fetch data from other service and update value every X minutes" can be effectively replaced with memo/ttl.


Ok, so I did some practiacl testing and it seems data will not be computed several times when there is a computation pending.

Lennart Buit11:10:52

Has anyone experienced segfaults with REBL / AdoptOpenJDK 11 on MacOS, and… have pointers on what to do to fix it

Lennart Buit11:10:12

It works perfectly fine on 8, but as soon as I switch to 11, I get segfaults

Lennart Buit11:10:45

Tried AdoptOpenJDK 15, also segfaults

Lennart Buit11:10:37

… bit vague, I know, I was kinda hoping that it rings a bell with someone :)

Lennart Buit11:10:03

It appears to segfault in libjfxwebkit?


You may want to examine the error file and loook for s corresponding jdk bug

Lennart Buit12:10:10

Yeah looking at logs, it is trying to find libraries in the maven repository > WARNING: java.lang.UnsatisfiedLinkError: Can’t load library: ~/.m2/repository/org/openjfx/javafx-graphics/11.0.2/libjfxwebkit.dylib > > Loaded library /libjfxwebkit.dylib from resource

Alex Miller (Clojure team)13:10:29

In Oracle Java 8, JavaFX is built in. In later Java’s, you need openjavafx as an additional set of libraries

Alex Miller (Clojure team)13:10:47

Are you using those deps?

Lennart Buit13:10:44

I’m using them in my lein profile:

{:tools {:plugins [[lein-ancient "0.6.15"]
                   [lein-localrepo "0.5.4"]]}
 :rebl {:repl-options  {:nrepl-middleware [nrebl.middleware/wrap-nrebl]}
        :dependencies  [[rickmoynihan/nrebl.middleware "0.2.0"]
                        [com.cognitect/rebl "0.9.242"]
                        [org.openjfx/javafx-fxml "11.0.2"]
                        [org.openjfx/javafx-controls "11.0.2"]
                        [org.openjfx/javafx-swing "11.0.2"]
                        [org.openjfx/javafx-base "11.0.2"]
                        [org.openjfx/javafx-web "11.0.2"]
                        [cljfmt "0.6.4"]]
       :resource-paths ["*snip*/REBL-0.9.220/REBL-0.9.220.jar"]
       :injections     [(require 'nrebl.middleware) (require '[cognitect.rebl :as rebl])]
       :jvm-opts       ["-Djavafx.verbose=true"]}
 :user [:tools :rebl]}

Alex Miller (Clojure team)13:10:28

But those are different versions

Lennart Buit13:10:30

Yeah, let me try with that 15 version, followed a bit of a mixed set of advice

Alex Miller (Clojure team)13:10:33

Even if you are on Java 11, you should use the newer javafx libs

Alex Miller (Clojure team)13:10:52

And you shouldn’t need the cljfmt dep

Alex Miller (Clojure team)13:10:56

You also seem to have one version of rebl in the deps and another in the resources?

Lennart Buit13:10:50

Yeah, I set it straight like this:

{:tools {:plugins [[lein-ancient "0.6.15"]
                   [lein-localrepo "0.5.4"]]}
 :rebl {:repl-options  {:nrepl-middleware [nrebl.middleware/wrap-nrebl]}
        :dependencies  [[rickmoynihan/nrebl.middleware "0.2.0"]
                        [com.cognitect/rebl "0.9.242"]
                        [org.openjfx/javafx-fxml "15-ea+6"]
                        [org.openjfx/javafx-controls "15-ea+6"]
                        [org.openjfx/javafx-swing "15-ea+6"]
                        [org.openjfx/javafx-base "15-ea+6"]
                        [org.openjfx/javafx-web "15-ea+6"]]
       :injections     [(require 'nrebl.middleware) (require '[cognitect.rebl :as rebl])]
       :jvm-opts       ["-Djavafx.verbose=true"]}
 :user [:tools :rebl]}
Those are the versions I found here: but in leiningens format I found some instructions by Sean, which was the mixed advice:

Lennart Buit13:10:55

Same problem tho, still get a segfault.

# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00000001047de1a4, pid=11576, tid=121871
# JRE version: OpenJDK Runtime Environment AdoptOpenJDK (11.0.8+10) (build 11.0.8+10)
# Java VM: OpenJDK 64-Bit Server VM AdoptOpenJDK (11.0.8+10, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# V  [libjvm.dylib+0x3de1a4]  jni_CallStaticBooleanMethodV+0xdf

Alex Miller (Clojure team)13:10:19

Those set faults were fixed in the openjfx 15 early access versions

Alex Miller (Clojure team)13:10:00

Or one set were, maybe this is something new

Alex Miller (Clojure team)13:10:18

I haven’t seen that before

Lennart Buit13:10:20

It’s also crashing with the released openjfx 15 versions. (e.g. ["org.openjfx/javafx-… "15"]). So that openjfx option I enabled, gives me this warning:

WARNING: java.lang.UnsatisfiedLinkError: Can't load library: *snip*/.m2/repository/org/openjfx/javafx-graphics/15/libprism_es2.dylib
Loaded library /libprism_es2.dylib from resource
(and of a bunch of other dylib’s) Is that expected?


@UDF11HLKC Which macOS are you on? Since I switched to the 15-ea+6 OpenJFX, I've had no problems on macOS 10.12, running AdoptOpenJDKs 11, 14, or 15.


I have seen that warning on Ubuntu (on WSL2 on Windows 10) but it still loads and runs just fine (via Xlaunch).

Lennart Buit14:10:17

I’m on Mojave 10.14


Is there anything specific that you do that results in the segfault, or is it random?

Lennart Buit14:10:36

Starting rebl, guaranteed segfault: (rebl/ui)


(I'll note that I don't use lein or nREPL at all so that may be a factor in what you're seeing)

Alex Miller (Clojure team)15:10:42

is there some reason you are using "15" and not "15-ea+6" as in the docs?

Lennart Buit15:10:29

(I guess that was at Sean? I tried both with the same results)

Alex Miller (Clojure team)15:10:35

I haven't actually tested rebl with the final 15 release

Lennart Buit15:10:42

Oh, I interpreted “Those set faults were fixed in the openjfx 15 early access versions” as “try final” 🙂. My bad, but I’m still having the crashes with -ea+6

Lennart Buit15:10:44

hey interesting, it works with a deps.edn

Alex Miller (Clojure team)15:10:16

I've used a bunch of different java vendors, and jdk versions, and open javafx versions and have never seen the issue you're reporting

Alex Miller (Clojure team)15:10:33

but I always use deps.edn, not lein so there may be some difference there, not sure what

Lennart Buit15:10:57

Really appreciate all the help so far 🙂

Lennart Buit15:10:49

I’m at least glad it works with a deps.edn, now its something lein related

Lennart Buit15:10:00

At least easier finding ^^

Lennart Buit22:10:03

For the internet travellers: For me, it doesn’t segfault when lein can find a project.clj, in folders that are not lein projects it does still, tho. Thats a situation that works for me, I think.


any niche application of (bounded-count) ?


my two cents, it's mainly for places where you want to know if (count x) is greater than some value y


... and on something not ICounted 🙂


oh, it actually does that check

Søren Sjørup14:10:41

With clj -X:deps mvn-pom is there a way to specify what version should be put in the pom file?

Alex Miller (Clojure team)14:10:12

not at the moment - you set it in the source pom

Alex Miller (Clojure team)14:10:40

but you should really use clj -Spom for now

Søren Sjørup14:10:50

Thank you for the quick response. Can I specify version on the command line with clj -Spom ?

Alex Miller (Clojure team)14:10:11

no, no difference in that regard

Alex Miller (Clojure team)14:10:05

the internals have been reworked to support that kind of configurability and that's coming but working on other things atm

Søren Sjørup14:10:14

Ok thanks a lot.


@soren.sjorup Since this question comes up a lot, I decided to write a script for it:

💎 3
Søren Sjørup14:10:46

Thank you so much. Big babashka fan!

Søren Sjørup14:10:58

My tags are qualified so I needed to change the condition to (and (:tag elt) (= "version" (name (:tag elt))))


ah I see, where is that difference coming from?

Søren Sjørup14:10:20

I have xmlns=“ in the project tag.


Ah, that makes sense. Feel free to PR the update if you so wish

Søren Sjørup14:10:56

Sure will do. Thanks a lot! Spent way to much time on this today.


Updated it already

Søren Sjørup14:10:40

(def xml (xml/parse-str (slurp pom-xml) :namespace-aware false)) also works.


ah good one


instead of that construction with and you could use the extra arg to the keyword

(= "version" (name (:tag elt "")))


I made it into:

(if-let [t (:tag elt)]
    (if (= "version" (name t))
      (assoc elt :content version)

Søren Sjørup15:10:13

with :namespace-aware false we don’t need name in there.


I leave the tweaking to the end user. However, I'm interested in a fix for getting the XML declaration and the first tag to be pretty printed better.


I'm actually getting:

<?xml version="1.0" encoding="UTF-8"?><project>

Søren Sjørup15:10:46

Yes I also get the <?xml and <project on the same line. But it’s not high prio for me.


you can also do a str/replace on that


To get the XML declaration straightened

Søren Sjørup15:10:15

Yeah sure. But I’m not going to read it. 🙂


That's the spirit :)

Søren Sjørup15:10:46

🙂 Again thank you so much for making babashka. I never got around to learning bash. But I love Clojure!


When running from CLI, is there anything to do to output the result? I have a very simple file and I can't get it to show anything.

(ns myns)

(defn -main
  [& args]
  (+ 1 2))
Running with clojure -m myns.


if you want to print to stdout you can use println.


Oh derp, of course.


Thank you very much


I'm halfway surprised -main doesn't return exit code 3


but only halfway :D

Alex Miller (Clojure team)15:10:03

that would be deeply weird :)


clearly I've been doing too much low-level programming lately


actually clj-kondo does return exit code 0, 2 or 3 with meaning attached to it


1 is reserved for unexpected errors


yeah, but that's quite different from using the last expression in -main as an OS level return value (and more useful of course)


Is babashka related to gravvl vm or something? How does that bb executable come from?


@UGC0NEP4Y It is related. Babashka is a tool that runs Clojure code through an interpreter that is compiled with GraalVM.


fast for interactive use?


It has worse performance than JVM Clojure, but better startup (few milliseconds).


just tried. quite fast. the only thing annoying is, when downloading the binary from github, chrome prompts that this file is seldom downloaded and might not be safe. Also, when execute the binary for the first time, macos says its not signed might not be safe ….


You can also install it through brew

Lone Ranger21:10:24

I'm very curious about the humble preserving-reduced function in the core library. Does anyone have any insight into this?

Lone Ranger21:10:04

I see that it's used in cat and if something is reduced it wraps it with another reduced ... that seems very strange but I'm sure there's a very good reason for it

Lone Ranger21:10:04

Also I understand that it's just an implementation detail of transducers but I can't for the life of me figure out what cases this covers.


if you have nested calls to reduce, as in cat, and the inner call to reduce short circuits with reduced, you don't want to resume reducing with the outer call to reduce


so you double wrap so that when the inner reduce short circuits, it unwraps one layer, then the outer reduce unwraps the other layer


cat is a transducer that is used in some reducing context which is the outer layer


the inner layer is the call to reduce that is on the last line of cat

Lone Ranger21:10:42

ohhhhhhhhhhkay that makes perfect sense


anybody gotten an uberjar to run under procrun on windows? keep getting an error saying it can’t find the class file. I’m able to call my gen-class static method using a java program with the uberjar on the classpath.


Have you checked the uberjar to see if the class is in there?


the first thing I would test is java -jar the.jar - you need more than just the class existing, you need to either ask for the right class or have the right default entrypoint


replaced my uberjar with a minimal one, which works. so now I just have to figure out whats different. thanks for the input!