This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-09
Channels
- # announcements (3)
- # babashka (17)
- # beginners (75)
- # calva (43)
- # cider (1)
- # clj-kondo (54)
- # cljdoc (8)
- # cljs-dev (70)
- # clojure (83)
- # clojure-europe (27)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (8)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (47)
- # community-development (4)
- # conjure (2)
- # cursive (3)
- # datomic (5)
- # emacs (5)
- # events (3)
- # fulcro (13)
- # graalvm-mobile (19)
- # helix (2)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (28)
- # kaocha (9)
- # livestream (11)
- # malli (15)
- # meander (24)
- # nextjournal (8)
- # off-topic (26)
- # pathom (1)
- # pedestal (8)
- # polylith (2)
- # portal (31)
- # re-frame (4)
- # reagent (10)
- # reitit (8)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (66)
- # spacemacs (20)
- # testing (6)
- # vim (15)
- # xtdb (7)
I have an agent bound to a top-level var in my program that, according to this https://stackoverflow.com/a/4610972, is blocking my program from exiting. Should I just avoid binding agents to top-level vars in general, or is there a preferred way to do so while allowing for graceful shutdown? It's ok if the answer is "don't bind agents to top-level vars", I'm just not sure how to proceed.
you can use shutdown-agents
- I do this in particular with code that leaves long running loops in futures (which use the agent send-off pool - the thing that delays shutdown)
one advantage of state management libraries like component / integrant etc. is that they provide a nice way to create your stateful things (including agents) without top level bindings
this makes repl development much easier (so you don't need to worry about dirty state as you iterate, and also don't need to mock up the stateful objects)
The thread pools that back agents and futures don't mark their threads as "daemon" threads
So if any code uses those thread pools, the vm will wait for those threads to exit before the vm exits, and those threads can take up to a minute to exit even if they are not actively doing anything
Hey all. While I can read resources from $project-root/resources
from tests in a deps.edn
project, I'm unable to do so from $project-root/test-resources
if I modify deps.edn
to
:test {:extra-paths ["test" "test-resources"]
Should I be able to using
?If you're running the tests with the :test
alias in play, I would expect so, yes.
Oh, now that's a good question. I need to figure whether Cider is doing that..
CIDER does not include the :test
alias by default. You can change cider-clojure-cli-global-options
to mend that.
Thank you - I will try this at lunch!
Does anybody else does something like that for dev-time REPL codes?
⢠create directory for yourself in src
⢠create there a sandbox.clj
with dev-time setup and snippets
⢠create there a .gitignore
file with *
as contents to never show it in git.
We generally encourage people to commit their REPL-time code in comment
-blocks at the end of namespaces, for all to enjoy. š
Similar, yes. But there's a mix of content blocks that are checked in, fiddles in a dev
directory that are also checked in (larger explorations), and some files that are git-excluded that may contain credentials or other information necessary for running locally but inappropriate for commit.
Does anyone here have any experience with https://github.com/ptaoussanis/sente? Iām falling at the first hurdle and struggling to know where to start debugging. Iāve followed (as far as I can tell) the āGetting Startedā instructions and the websocket is not connecting. I see this in my browser console:
WebSocket connection to '' failed:
2022-02-09T12:57:00.142Z ERROR [taoensso.sente:1187] - WebSocket error: [object Event]
The response from the server looks OK (the āNetworkā panel of the browserās developer tools seems to think the connection is established) so this seems to be a client-side issue. But I donāt really know where to start looking to identify whatās up.
Suggestions would be very welcome!I do not know the solution to your problem, but I remember struggling with CSRF. I think sente requires it by default, but that it can be turned off.
> I see this in my browser console
> WebSocket error: [object Event]
What's that [object Event]
? If that's exactly how it looks and you can't expand it, it means that Sente has turned some (Event. ...)
into a string. Can't really go on from here without first getting access to the original value, before it was turned into a string. But it should be relatively easy to do - you can debug CLJS fairly painlessly in your browser, especially if you have cljs-devtools
installed. You already have the location - it's taoensso.sente:1187
.
Yeah, itās a string and canāt be expanded š
Iāve been doing some experimentation with implementing websockets ārawā via info.sunng/ring-jetty9-adapter
and Iāve got a very simple example up and running.
Given that I donāt think I need much of the cleverness that Sente brings (I donāt need to fallback to long-polling, for example), I may stick with that for now at least.
I'm working on a new question for the Clojure survey something along the lines of "What caused you to start learning Clojure?" and I'd be interested in hearing candidate answers to that question if you want to thread reply those here
āWanted to learn a functional language and my first choice wasnāt an obvious possibility.ā
let's try to keep it to actual possible things I might put in a survey please...
Bored of being a Java (or X) developer, wanted to try something completely different (but still practical)
I may split this up into a "how did you hear" and "what attracted you"
My AP CS teacher told me about it by showing me a circuit simulator he made with seesaw
So possibly some answer that indicates a mentor introduced you to it, or that a class required it
if we can keep this less jokes, more real answers, that would be helpful to me
(if my answer seemed like a joke, I was not joking. I had wanted to use a lisp since college but in a work environment that just seemed like a non-starter. Clojure allowed using a lisp but with modern value propositions, on a .NET team. Something like common lisp or chicken scheme would never fly)
> "Wanted to learn a functional language" was a necessary but not sufficient condition for me. Already being a Java dev made Clojure more accessible, since I already knew the platform. Without that factor, I'd have probably gone for Haskell.
Not sure how to boil that down to a punchy survey answer, but there's some raw data
I was curious about LISP and coming from Java, Clojure, along with its friendly community, seemed more approachable to me than my initial explorations in Scheme.
"I liked using it more than any other language I had previously tried."
"Intrigued by articles on the power of lisps". Intrigued by all the brilliancy of lisps and how there was all this "ancient knowledge" just now being rediscovered by modern languages. That and a few articles by Paul Graham and all the people saying that programming in a lisp would rewire your perspective. Which it did.
"Driven by StackOverflow survey results". More in deep: - wanted to learn FP (to rewire brain) - wanted to learn LISP (to rewire brain) - would have access to JVM and Java ecosystem - mostly experienced devs using it, which means they actually chose this language and are not in it because market needs like JavaScript/PHP (based on surveys) - people that use Clojure seems to love it and not dread it (based on surveys)
āAn open source project i wanted to contribute to is written in clojure so i learned it for that purpose and branched out.ā (Iām not sure how to condense that into a pithy answer)
"I wanted to see how it made game development either easier or harder and in which ways."
I'm fairly sure what first got me interested in Clojure was one of Chris Granger's blog posts (https://chris-granger.com/archive/) and, by extension, seeing and trying out Light Table. I unfortunately forget which post it was exactly.
Eric Normand's interview on The Changelog is what got me curious about Clojure, which turned out to check a number of boxes: ⢠It's a functional language ⢠It's a Lisp (I'd never used a Lisp before) ⢠It runs on the JVM (at the time I was curious about the JVM, but not interested in learning Java) ⢠It's not statically-typed, which is different than the other functional languages I was familiar with.
Thinking of grid with cols "What first attracted you to learn Clojure?" and "Why did you keep using it?" and rows: * Functional programming * REPL development * Learning a Lisp * Interop with Java * JVM deployment * Use in a browser * Immutable data * Support for concurrency * Dynamic typing (or less ceremony around types) * Expressiveness * High performance * Whole stack use * Code as data / macros / homoiconicity * Welcoming / helpful community * Required for a class * Required for a job * Just curious
and maybe a separate open response for "how did you first hear about it?"
Had already been doing FP in Elm/Haskell for a few years, knew bits and pieces about Clojure. It was specifically watching Datomic talks that really made me want to dive in.
I saw a simple demo explaining what it is and why it's good and that was both the introduction and the reason I became interested
another reason Iāve seen is something along the lines of, Clojure is a strong signal for programmer competence. some companies Iāve talked to have selected clojure for this reason. maybe something like āIt looks good on a resumeā?
[I know Iām late to this thread, but I didnāt see anyone else mention thisā¦] https://blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html I read this about the same time as I was admitting to myself that I had reached the limits of my then-current tools and knew I needed something different. Clojure for the win!
Burnout from Java's concurrency model. Started with https://pragprog.com/titles/pb7con/seven-concurrency-models-in-seven-weeks/ and that led to Clojure š
Curiosity, AKA "I was exploring other/new/different languages & programming paradigms" (+ "I wanted to try functional programming", which has been already mentioned previously)
Can I customize the output location for Clojure's stack trace EDN on exceptions with an environment variable or property? (e.g. the full report available at /tmp/clojure-*.edn
bit when the program crashes). It would help with some cross-OS compatibility pain points I'm facing with running my tests in CI.
You can customize it by overriding the "
property. But note that it's a process-wide setting.
I'm currently writing a macro that operates on a fully qualified symbol. Is there a built-in function that strips the namespace off a qualified symbol and returns the simple symbol i.e. some.namespace/my-function
-> my-function
Maybe https://clojuredocs.org/clojure.core/name And this may be helpful https://clojuredocs.org/clojure.core/namespace
(Let me say it's usually advised to avoid writing macros as much as you can)