Fork me on GitHub

Are there any real performance difference between inline and external protocol implementations? How to choose which one to use if you can change the type? From “Clojure Programming” I understood that the main benefit of inline implementation is the performance, and probably should use extend* — while I mostly see defrecord/ deftype (I guess)


Not sure i did the right thing on measuring performance, but :

(defprotocol Noop
  (dont-do [this]))

(defrecord InlineNoop []
  (dont-do [_] nil))

(def inline-op (->InlineNoop))

  (dont-do inline-op)) ;; ==> Execution time mean : 2.100368 ns

(extend-type String
  (dont-do [_] nil))

  (dont-do "asd")) ;; ==> Execution time mean : 2.118537 ns


> Thus, inline implementations, while tempting because they appear so familiar (methods > in classes!), are more static than other protocol extension mechanisms, and are best > kept as an optimizing step. (Clojure Programming)


Hello! May I know what are good ways to debug clojurescript in production/in a docker?


Also if I compile my code into a jar, and I have the code (shell/sh "python3" "resources/" "10") how do I make sure my program refers to the "resources" folder in my jar ?

Cora (she/her)13:08:29

and then use whatever your build tool is to add that path to your jar


I just tried that but that will return an object like for the code

( "")


Otherwise I am using lein and the resources folder is already being added to the jar it produces

Cora (she/her)13:08:58

can you try .getPath on that object and see if that works?


Right i think this might work tho I need to test how that might work from a jar hmmm

Cora (she/her)13:08:39

all else fails you can read the file in and write to a tmp location and run it from there


Yeap that kinda was what I was thinking

Cora (she/her)13:08:31

you could slurp in the resource and then pass that as the value to -c


Right I guess I'll try that next hahaha

Cora (she/her)13:08:48

sorry, I'm obviously guessing at all of this


no worries 🙂 is cool!


@corasaurus-hex seems like .getPath doesn't really work in the case of a jar Caused by: /home/zackteo/Documents/Capstone/Clojure/URA-Capstone-Frontend/deploy/ura-site-search-0.1.0-SNAPSHOT-standalone.jar!/Single-Objective-Models/ (No such file or directory)

Cora (she/her)14:08:34

I suppose that makes sense since it's located inside a zip file

Cora (she/her)14:08:45

the .deleteOnExit is really nice to have


I meet a problem when trying lein test the error is Caused by: java.lang.ClassNotFoundException: clojure.set and in the file, it is written

(def solution-10
  (loop [nums (set (cons 2 (range 3 2000000 2)))
         n 3]
    (if (> (* n n) 2000000) (reduce + nums)
        ;; else
        (recur (clojure.set/difference nums (range (* n n) 2000000 n))
               (+ n 2)))))
what the fuck? I can run it on repl, but I faild in test ??


namespaces can be preloaded by a repl that aren't loaded in a regular process, no clojure namespace other than clojure.core is guaranteed to be loaded before you require it


@steiner3044 is it possible that you imported clojure.set in your repl already but its not available from your testrunner?


@alpox may I ask, how ?


In the REPL: (require '[clojure.set]) In a namespace form:

(ns xyz
  (:require [clojure.set]))


thanks 🙂


just add a require to it in your namespace. (ns the-ns (:require [clojure.set :as set])) and then use set/difference


I was suddenly confused, again, trying to use Reveal with Atom/Chlorine. Reveal eats prepl, Chlorine wants socket repl. Probably a thousand ways to wire it up anyway, but I’m not fluent in repls enough to improvise. Help or pointers much appreciated, general or specific to my situation 🙂

Jelle Licht21:08:37

How can I run tests that depend on genclass -shenanigans in a deps.edn + build.clj based project?


@wordempire You need to run the compile step, then run your tests: is not intended as a test runner (although we've made that work by using java-command and process to run tests as a subprocess).

Jelle Licht23:08:26

I already have my test-runner set up under a deps.edn alias; I currently have to run run my compile command, and then run the test runner; what exactly are you suggesting here? Having some step call out to my test runner alias using java-command or process?


"I currently have to run run my compile command, and then run the test runner" -- that is the expected workflow.


But at work, we've used create-basis, java-command, and process to run tests from build.clj. It's non-trivial but possible.


If you normally run tests via -M:test, the you'd create-basis with {:aliases [:test]} and pass the basis to java-command along with a vector of command arguments, like :main-opts plus whatever else you'd provide on the command-line, and then you pass the result of that into process. I should write up an example of it on my blog -- or incorporate it into one of my OSS projects so folks can see how it is done.


Like so:

(! 1672)-> head deps.edn 
{:paths ["src"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"}
        org.clojure/ {:mvn/version "1.0.86"}

        camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}}
 {:build {:deps {io.github.clojure/ {:git/tag "v0.1.7" :git/sha "8a3abc2"}}
          :ns-default build}
  :test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
(! 1673)-> cat build.clj 
(ns build
  (:require [ :as b]))

(defn run-tests
  (let [basis (b/create-basis {:aliases [:test]})
        cmds  (b/java-command {:basis     basis
                               :main      'clojure.main
                               :main-args ["-m" "cognitect.test-runner"]})]
    (b/process cmds)))
(! 1674)-> clojure -T:build run-tests


You can see the whole deps.edn here: (for the rest of the :test alias that has the Cognitect test-runner in it.

Jelle Licht23:08:42

Thank you! This was pretty much what I was looking for (and not understanding) until you clearly laid it out here.