Fork me on GitHub
#clojure
<
2024-06-12
>
bruno.bonacci09:06:48

Hi all, at the London Clojurians talks we have got some requests to cover the libraries like: Component, Mount, Integrant etc in one of our future talk. is there anyone interested in preparing such talk? maybe showing comparatively how they work with the same examaple? If anyone is interested into talking about any of the above libraries (one or all), please get in touch with me I will be happy to organise a talk for you.

practicalli-johnny10:06:54

I've used Integrant (Integrant REPL) and donut-party/system approaches commercially, so I could do a talk on those. They are also available with new projects created with https://practical.li/clojure/clojure-cli/projects/templates/practicalli/ I've taken a repl reloaded approach with both approaches. I've also done simpler projects without any component library.

bruno.bonacci11:06:07

That would be perfect, the talk could illustrate the differences and the http://practical.li templated/articles could be used as follow up. I will DM you to organise it.

slipset17:06:08

Haven’t got the system to prove it, but at some point I wish I were ready to give a talk called something like “KISS: Coding without dependency injection”. Perhaps @U04V5V0V4 could help me?

ray17:06:51

ooh ooh yeah ... I'm up for that heresy

ray17:06:14

file watcher + a way to reload is usually good enough ... a lot depends on whether you are starting services yourself and often it's just one (the web server)

slipset20:06:07

I guess my claim (and perhaps @U04V5V0V4s) is that for most systems, your stateful things are just a handful, and you don’t need to build a graph to sort out their dependencies. With system like Component et al, you’re tricked into making way more stateful things than need be.

ray20:06:20

Nailed it

pieterbreed10:06:00

I've retro-fitted integrant into a few projects that grew from small-and-too-simple-for-DI into bigger systems that had trouble either starting up or restarting reliably. Each time it was a royal pain, with fairly large refactorings that did not add any business features. My default advice is to just use integrant on new projects...

lukasz14:06:49

Definitely something that requires consideration- in my case there is a business value since majority of services do not cleanly shutdown resources when they’re being stopped during rollouts - we could add to the mess and setup JVM shutdown hooks of course but that just adds to the mess in few places. And yeah, I retrofitted Component before, it was painful but paid off in the end

ray06:06:37

This came up recently and I’m :star-struck:

ray06:06:54

@U9RRPR0KE we are not worthy. This is genius.

bruno.bonacci09:06:51

Following up this request we are organising the following event, Thanks to @U05254DQM The London Clojurians are happy to present: *Data Driven Component Libraries from commercial experiences (by Johnny Stevenson)* https://www.meetup.com/London-Clojurians/events/301916548/ Johnny will be talking about how to use effectively *Integrant, donut-party/system and Juxt/Aero* with a REPL workflow.

👍 1
Eugen16:06:32

any idea how can I fix reflection in this case with 1.12 features?

(def pac4j-anonymous-client ^Client (AnonymousClient.))

(def pac4j-clients ^Clients (doto (Clients.)
                              (.setCallbackUrl "/callback")
                              (^[List] .setClients [pac4j-form-client])))

; Reflection warning, /home/ieugen/proiecte/clojure/snm/dev/ring_pac4j.clj:45:31 - call to method setClients on org.pac4j.core.client.Clients can't be resolved (argument types: clojure.lang.IPersistentVector).
https://github.com/pac4j/pac4j/blob/master/pac4j-core/src/main/java/org/pac4j/core/client/Clients.java Clients use overloaded methods for List, varargs and array of Client

Eugen16:06:26

this kind of works but Calva complains about missing closed parens

(def pac4j-clients ^Clients (doto (Clients.)
                              (.setCallbackUrl "/callback")
                              (.setClients ^Client/1 (into-array Client [pac4j-form-client]))))

p-himik16:06:56

If I'm reading the code of Clojure itself correctly, it's because expressions like [...] are tagged with IPersistentVector, which does not extend List. If so, you should be able to make it work by using (.setClients ^List [...]).

hiredman16:06:36

there is a bug, I believe still open, where you cannot hint literal collections

👍 1
p-himik16:06:41

> Calva complains about missing closed parens Sounds like something Calva should fix. :)

p-himik16:06:15

> there is a bug Ah. Well, let's bind it then.

hiredman16:06:56

or call identity on it

Alex Miller (Clojure team)16:06:11

I think if you qualify the setClients it should work, param-tags are only used on qualified methods

Eugen16:06:47

seems like this did the trick, thank you all

(^[List] Clients/.setClients [pac4j-form-client])

Eugen16:06:13

looks kind of strange though 🙂

Alex Miller (Clojure team)16:06:16

Yeah, feels redundant here in the doto but it’s part of minimizing new semantics for existing syntax