Fork me on GitHub
#clojure
<
2022-02-09
>
respatialized01:02:02

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.

noisesmith02:02:19

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)

noisesmith02:02:16

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

noisesmith02:02:04

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)

hiredman02:02:28

Top level bindings have nothing to do with exiting or not

hiredman02:02:02

The thread pools that back agents and futures don't mark their threads as "daemon" threads

hiredman02:02:13

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

hiredman02:02:33

That stackoverflow answer starts ok and veers off into nonsense pretty quick

hiredman02:02:50

agents will never be gc'ed if they have work in their queue

paulspencerwilliams07:02:24

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 ?

seancorfield07:02:42

If you're running the tests with the :test alias in play, I would expect so, yes.

paulspencerwilliams07:02:49

Oh, now that's a good question. I need to figure whether Cider is doing that..

magnars07:02:53

CIDER does not include the :test alias by default. You can change cider-clojure-cli-global-options to mend that.

šŸ‘ 1
paulspencerwilliams07:02:00

Thank you - I will try this at lunch!

paulspencerwilliams07:02:52

Thanks @U07FCNURX, that worked a treat.

šŸ‘Œ 1
vlaaad12:02:20

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.

magnars12:02:18

We generally encourage people to commit their REPL-time code in comment -blocks at the end of namespaces, for all to enjoy. šŸ™‚

R.A. Porter13:02:58

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.

jjttjj15:02:28

Yes, I do almost exactly this

šŸ‘ 1
paulbutcher13:02:38

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!

Nom Nom Mousse13:02:33

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.

p-himik14:02:12

> 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.

paulbutcher15:02:37

Yeah, itā€™s a string and canā€™t be expanded šŸ˜ž

paulbutcher15:02:54

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.

paulbutcher15:02:26

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.

Alex Miller (Clojure team)16:02:21

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

Alex Miller (Clojure team)16:02:07

"Used in a college/university class"

āœ… 3
Alex Miller (Clojure team)16:02:14

"Required to learn for a job"

āœ… 4
Alex Miller (Clojure team)16:02:21

"Wanted to learn a functional language"

āœ”ļø 17
Alex Miller (Clojure team)16:02:28

"Wanted to learn a LISP"

āœ”ļø 21
potetm16:02:00

ā€œWanted to learn a functional language and my first choice wasnā€™t an obvious possibility.ā€

Alex Miller (Clojure team)16:02:01

let's try to keep it to actual possible things I might put in a survey please...

Alex Miller (Clojure team)16:02:23

"Heard a talk by Rich Hickey"

āœ”ļø 17
R.A. Porter16:02:07

"Wanted to use a LISP integrated with the Java ecosystem."

šŸ‘ 2
dharrigan16:02:23

Bored of being a Java (or X) developer, wanted to try something completely different (but still practical)

āž• 4
dharrigan16:02:47

To challenge myself

āœ”ļø 2
dharrigan16:02:31

To Stop Using The Spring (Boot) Framework For Everything

šŸ˜† 1
ā˜ļø 1
dharrigan16:02:11

To Return To Simplicity/Basics.

Alex Miller (Clojure team)16:02:10

I may split this up into a "how did you hear" and "what attracted you"

šŸ‘ 6
Joshua Suskalo16:02:19

My AP CS teacher told me about it by showing me a circuit simulator he made with seesaw

dpsutton16:02:45

It allowed me to use a lisp in production without being laughed at by my team

Joshua Suskalo16:02:06

So possibly some answer that indicates a mentor introduced you to it, or that a class required it

Alex Miller (Clojure team)16:02:11

if we can keep this less jokes, more real answers, that would be helpful to me

dpsutton16:02:31

(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)

āž• 1
Colin P. Hill16:02:15

> "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.

Colin P. Hill16:02:52

Not sure how to boil that down to a punchy survey answer, but there's some raw data

lread16:02:05

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.

respatialized16:02:39

"I liked using it more than any other language I had previously tried."

mbjarland16:02:52

"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.

Marcelo Fernandes16:02:13

"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)

Noah Bogart16:02:49

ā€œ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)

šŸ‘ 2
Kelsey Sorrels16:02:15

"I wanted to see how it made game development either easier or harder and in which ways."

James Amberger17:02:00

To get away from JS

šŸ‘ 1
flowthing18:02:58

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.

šŸ’Æ 1
emccue18:02:52

ā€œlearned a lisp in college and then didnā€™t want to waste that time investmentā€

mjw19:02:28

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.

Alex Miller (Clojure team)19:02:33

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

Alex Miller (Clojure team)19:02:52

and maybe a separate open response for "how did you first hear about it?"

R.A. Porter19:02:43

You're thinking just check all that apply, right?

āž• 5
nicklawls19:02:18

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.

dixie19:02:23

Hackernews and LISP articles.

Nundrum20:02:17

Peer pressure

Nundrum20:02:44

Accessibility of an expert

Nundrum20:02:25

Claims that it would expand my mind more than ayahuasca

šŸ˜† 1
Alex Miller (Clojure team)20:02:56

I actually thought about putting "Secret powers" on there :)

āž• 2
lread20:02:02

Iā€™m a fan of mirth and secret powers, fwiw, Iā€™d add it!

isak20:02:01

Paul Graham essays

ā˜ļø 1
nonrecursive19:02:06

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

nonrecursive19:02:47

My suggestion for the grid is "Makes programming enjoyable"

ā˜ļø 2
nonrecursive19:02:42

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ā€?

wevrem16:02:21

[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!

imre19:02:34

Watching Robert Martin's talk "the last programming language" made me try it

šŸ¤Æ 1
the2bears19:02:59

Burnout from Java's concurrency model. Started with https://pragprog.com/titles/pb7con/seven-concurrency-models-in-seven-weeks/ and that led to Clojure šŸ™‚

Mario Giampietri22:02:25

Curiosity, AKA "I was exploring other/new/different languages & programming paradigms" (+ "I wanted to try functional programming", which has been already mentioned previously)

respatialized16:02:28

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.

p-himik16:02:14

You can customize it by overriding the ".tmpdir" property. But note that it's a process-wide setting.

āœ”ļø 1
respatialized16:02:33

that's OK, it won't affect anything else if I override it in CI. Thanks!

šŸ‘ 1
Alex Miller (Clojure team)16:02:20

you can also direct to stderr and pipe to wherever you want

āœ… 1
alex21:02:55

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

paulocuneo21:02:40

(Let me say it's usually advised to avoid writing macros as much as you can)

šŸ™ 1