This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-24
Channels
- # announcements (3)
- # babashka (3)
- # beginners (34)
- # calva (6)
- # cider (4)
- # clerk (5)
- # cljs-dev (1)
- # clojure (47)
- # clojure-europe (41)
- # clojure-norway (1)
- # clojurescript (59)
- # cursive (5)
- # data-science (9)
- # datascript (14)
- # events (1)
- # fulcro (5)
- # guix (14)
- # helix (7)
- # hoplon (5)
- # hyperfiddle (2)
- # kaocha (8)
- # lambdaisland (1)
- # lsp (24)
- # releases (1)
- # scittle (31)
- # shadow-cljs (10)
- # tools-build (2)
Hello, I’ve read some discussions on having a feature like common lisp core images on clojure, but they are old: https://groups.google.com/g/clojure/c/qZEkdlZKNQs/m/FYkjBJFAnGUJ https://groups.google.com/g/clojure/c/CR1bWntExYo/m/5BQg-PadbXgJ https://groups.google.com/g/clojure/c/YZjbfYJhApM/m/_RS7jhJX0c4J I kind of recently learned about this Common Lisp feature so I was wondering if this is something that people have done already and I just can’t find a library to do it. Does anyone know about this? Beyond that, any recommended readings on this feature in CL? Thanks in advance!
It's kind of limited by the JVM, since that's the runtime. So I don't Clojure could do much, unless the JVM offered a reliable feature for it.
It does have some things like app-image, but they're finicky and not similar to CLs
I couldn't find it but I think I remember reading some recent conversation on image-saving/heap-dumping for JDK, maybe as part of project Leyden ? I don't know
Looking at Leyden and will see if there’s related stuff that could be into it, really interesting!
Regarding my last question about how to do SSL properly, I think I've managed it without hitting the pitfalls described to me by others here and by the less-awful-ssl
library itself.
I have a cert and key pair fetched from LetsEncrypt as-is (without converting as advertised by less-awful-ssl
), to which I do:
(defn server-config [port]
{:port port
:join? false
:ssl-context (ssl/ssl-context "privkey.pem" "fullchain.pem")
:ssl-port 3001
:client-auth :want})
(def server (ring/run-jetty (wrap-params #'handler) (server-config port)))
And this seems to work just fine both in the browser and via curl
. Have I missed some landmine?
If it matters, I'm current running this on Java 17.Not familiar with the library, but looking at the conversion in the readme I think you would only need it for Java 8
PKCS12 keys are supported since 9
Great, thanks
Looks like something has changed in the JVM sometime between 11 and 20 that has affected Clojure reflection handling. (Thread/sleep (rand-int 1000))
works on 11 but throws a reflection error on 20.
This is on Clojure 1.10.1 but 1.11.0, 1.11.1, and 1.12.0-alpha4 exhibit the same behaviour. I haven’t tried other JVM versions yet; I’ll post updates in comments as I gather more info.
What gives? Does anyone have any idea?
You can search for Thread/sleep
in this channel - it has popped up at least twice before.

Indeed, thank you very much! Here’s one thread: https://clojurians.slack.com/archives/C03S1KBA2/p1681401318390539
And here’s an explanation from that thread: https://clojurians.slack.com/archives/C03S1KBA2/p1681401484638789?thread_ts=1681401318.390539&cid=C03S1KBA2
Here's https://ask.clojure.org/index.php/12853/built-in-function-for-thread-sleep-to-avoid-type-hints, upvote if you like it!
@UE21H2HHD I don't understand that at all. Instead of fixing Clojure's reflection bug, we're hoping to special-case every present and future case where the JDK adds an arity?
Hiya @U0HG4EHMH the problem is that the JDK changed the fn signature. I don't see it as a problem in Clojure itself. Steering folks to a convenience sleep fn seems like an OK way to address/adapt.
Huh, weird. Can't reproduce it now on JDK 20 and Clojure 1.11.1. Tried REPL, -i
, -e
, -m
. Made sure that Thread/sleep
does have three arities, two of them with just one argument.
Although thankfully it's not part of my daily workflow, from time to time I have to type
(require 'foo.bar.baz)
(in-ns 'foo.bar.baz)
into a terminal, by hand. Would it not be possible for Clojure to provide a handy helper? Is it not simple for some sort of wicked repl reason?In the https://clojuredocs.org/clojure.core/await, the wording seems to imply that an agent can send an action to another agent and wait for it to finish. However, I tried to write some code to that effect, and got an error
(def m
(agent {:agent (agent 0)}))
(defn stepm
[m]
(await (send (:agent m) inc))
m)
(send m stepm)
When I try to run this code, at first nothing happens, since @(:agent @m)
evaluates to 0 still. Then, when I try to rerun the (_send_ m stepm)
line, I get a runtime error saying "Can't await in agent action_."_ which seems to imply the opposite of what the clojure page says. Does anyone know what's going on? Thanks! It's not typical to nest agents. It's not totally clear what you're trying to do. Maybe something like:
(def m
(agent {:num 0}))
(defn stepm
[m]
(await (send m update :num inc))
m)
(stepm m)
Agents are rarely used. Using atoms is much more common.
It does seem like the docstring is contradicting the behavior, whether or not it's useful to do.
ohhh, I think I understand the question better now. If you wrap sendm
with a try/catch, you can see the error:
(def m
(agent {:agent (agent 0)}))
(defn stepm
[m]
(prn m)
(try
(await (send (:agent m) inc))
(catch Exception e
(prn e)))
m)
(send m stepm)
;; Exception: "Can't await in agent action"
This makes sense since all agents share a thread pool, so agents awaiting other agents could cause deadlock in some cases. Either way, it's probably not what you want.Yeah, I think the specific concern is that the docstring is confusing > Blocks the current thread [...] until all actions [...] from this thread or agent [...] have occurred.
There's things about await that make it far from ideal to use as well, like it never returning if a failed agent is restarted with clear-actions or when shutdown-agents are called.
I'd more or less say to avoid await if you can
Seems reasonable. The docs have the wiki which can be helpful. You could also describe the issue on http://ask.clojure.org
What would anyone recommend for a good Clojure course/tutorial that would provide a good base for interviewing for clojure jobs
Practicalli, Lambda Island (now free!), and Eric Normand's courses come to mind
Do you have links?
https://practical.li/ https://lambdaisland.com/ https://ericnormand.podia.com/beginning-clojure
Read books. I really liked https://www.amazon.com/Clojure-Programming-Practical-Lisp-World/dp/1449394701/ref=mp_s_a_1_1?crid=1WTPRZACWZHT6&keywords=clojure+programming&qid=1690236679&sprefix=clojure+programming%2Caps%2C337&sr=8-1 by Emerick, Carper, Grand. It was good for me as a beginner but it is deep as well. You need only the first two parts of it (cca 300 pages). Maybe read https://www.manning.com/books/the-joy-of-clojure-second-edition after that.
Some great books that cover databases, which may be relevant for interviews. https://www.amazon.com/Performance-Explained-Everything-Developers-about/dp/3950307826 https://dataintensive.net
@U8LB00QMD do you know where to find that Eric Normand course for free?
Lambda Island seems really cool
They're professional grade courses used for company onboarding, and it's his livelihood, so unfortunately not
Many Clojure interviews have some kind technical test (sometime incorrect described as pairing). So practicing Clojure via small challenges may be quite useful. http://Exercism.com has lots of interesting challenges to solve and http://Practical.li has some solution walk-throughs to read that try different approaches (try solve the challenges first before though) 4Ever Clojure also has challenges to help learn the functions in the standard Clojure library https://practical.li/clojure/coding-challenges/