Fork me on GitHub
#clojure-uk
<
2019-01-29
>
alexlynham09:01:56

morning morning

rickmoynihan09:01:51

@wesley.hall: I would definitely go with integrant (or duct). mount is very inflexible as it effectively makes everything a singleton.

rickmoynihan09:01:10

Almost all of our apps use integrant these days.

maleghast09:01:49

@wesley.hall - I would also vote for Integrant; it's the direction we are going in...

rickmoynihan10:01:20

Also a colleague who’d used mount extensively at a former place of work (though reported no issues with it); is now a convert to integrant now he’s using it.

alexlynham10:01:07

I used to be a big fan of mount and then rick converted me to integrant, tend to just use that now

Wes Hall10:01:15

No love for "component" here then 🙂.

alexlynham10:01:24

although... I've found showing clojure newbies mount makes life much much easier

alexlynham10:01:37

and then giving them the option of integrant

rickmoynihan10:01:46

component is fine — but you just end up rebuilding integrant, as you almost always want to move the system to configuration.

Rachel Westmacott10:01:13

can you unpack “move the system to configuration” a little for me?

Wes Hall11:01:47

@U0FR9C8RZ I think I probably can. I think the point here is that it is idiomatic in integrant to place the configuration of your system in an EDN file. The library reads this file and constructs a system. You essentially just map keywords to component factory functions. In component, this is not really a thing and systems are composed in code, from code... so I think what Rick is saying here is that with component, you often end up creating your own config -> code system.

Rachel Westmacott11:01:44

I think of the declarative Clojure code that defines my system map as config. (albeit config in a fully featured programming language) So I’m not sure I see the difference.

Rachel Westmacott11:01:50

code == data, etc. etc.

mccraigmccraig12:01:14

@U0FR9C8RZ the nice thing about literal data for system config is that whatever is building the system can easily traverse the structure and e.g. sort by the dependency partial-order, or you can use things like aero to configure/specialise your system

mccraigmccraig12:01:07

if it's code then sure, you can traverse the code tree but that's quite possibly got opaque structures in it (closures, function refs) so it's not so easy

rickmoynihan12:01:25

@U0FR9C8RZ: I think the others in this thread have explained most of the differences. As I said “component is fine”, it’s pretty much the same as integrant; but it’s effectively a config map in a clj file. It can be useful to be able to expose that map as configuration file so people can modify or effect values in the system in different contexts - e.g. production vs staging vs dev vs test without changing code. With component you have to do this work yourself. Or add some notion and wiring of special configurable bits of the system. Integrant / duct gives you all the pieces you need to separate this out. Without needing much extra glue. Also it’s worth saying that you can get a lot of power by then meta-merging these maps in a precedence chain. Typically we’ll have an override chain that gets merged into the final system e.g. (meta-merge [base-config customer-config env-config]) so you can configure different overrides without having to duplicate the whole system map.

rickmoynihan12:01:17

Also integrant has some great features, such as hierarchies, refsets, and composite keys. Which are really useful concepts component doesn’t really have.

Rachel Westmacott13:01:43

cool, thanks all for unpacking

Rachel Westmacott13:01:19

we use component extensively but have an item on a todo list somewhere to take a look at Integrant, because people keep recommending it

rickmoynihan13:01:59

depending on the project it’s probably not worth switching, unless you want things to be more configurable, and adding a config system is about the same amount of work as porting. Like I said component is fine, integrant isn’t much different. I’d certainly consider using it in greenfield projects over component. It’s much better than mount, and far more flexible. mount’s singleton design is a big problem in my mind.

alexlynham10:01:05

I need to bump the versions in the project clj but I use this as a template to show people new to integrant roughly how it fits together https://github.com/the-frey/compojure-api-integrant

alexlynham10:01:10

there's some things that aren't perfect about it, but it shows the idea well enough

Wes Hall10:01:07

Looks like all the love goes to integrant 🙂. To be honest, it's my favourite too, so I am happy to be validated. Thanks for input folks.

guy10:01:00

So a fun little thing I found out the other day: https://clojuredocs.org/clojure.pprint/pprint#example-5591ab88e4b05f167dcf2345 pprint to a file. So when it comes to saving json pprint it can be quite nice :thumbsup:

jasonbell13:01:50

Nice one @guy, that’s handy

👍 5
jasonbell14:01:26

And just found out about ex-data over lunchtime, that was a new one.

maleghast14:01:09

King Crimson, nice one @jasonbell 🙂 What's ex-data ?

jasonbell14:01:45

@maleghast i) I was there 🙂 ii) ex-data turns thrown Exception data in to a map.

jasonbell14:01:34

With caveats Returns exception data (a map) if ex is an IExceptionInfo.

maleghast14:01:20

Even so, that's pretty cool 🙂

Ben Hammond14:01:57

sorry to lower the tone; has anyone got a good link to the content of yesterday's immigration bill? I got put an end to free movement of people and sweeping Henry 8th powers all the press sounds so awful that I just wanted to double check

Ben Hammond14:01:12

bah. Bureaucrats vote for an increase in bureaucracy

thomas14:01:34

makes perfect sense to me...

Ben Hammond14:01:20

I shudder when I have to deal with the Home Office wouldn't wish it on anybody

thomas14:01:23

why do you think I have done my Brexodus?

Ben Hammond15:01:09

perhaps I'm still in denial. doesn't seem to be an emoticon for that ;'(

alexlynham15:01:02

🎵 brexodus, movement of high-skilled people 🎶

otfrom15:01:41

lots of Labour abstainers. Only a single line whip and that was after a lot of pressure from various sides. Not really what I hoped for from Labour, but what I've come to expect. (I always assume the Tories are going to be bastards on things like this, esp under May, but was hoping that Labour might at least show some leadership here)

Ben Hammond15:01:45

Pete Wishart is my MP. I didn't vote for him, but I'm glad he got in anyway

otfrom15:01:43

he's good to follow on twitter

Ben Hammond15:01:24

he seems to be madly tweeting from inside the chamber

otfrom15:01:28

I'm pretty happy with my west Dundee MP Chris Law.

Ben Hammond15:01:29

or his office is

otfrom15:01:48

I think it is actually him

thomas16:01:26

Steve Brine (my so called MP, as I couldn't vote) seems to be invisible as far as I can tell... he just follows the party line (conservative)

thomas16:01:21

I did write to him telling that Brexit was one of the reasons I left and I got back a very none answer

thomas16:01:18

But we once did get a handwritten letter from him saying that he understood our frustration at not being able to vote in the UK (for Westminster) and yet having to pay income tax.

dominicm16:01:07

uh, tl;dr. There's a plan to end EU immigration?

maleghast14:01:08

I don't really have time to read that right now, @ben.hammond but thanks for the link

Wes Hall14:01:36

ex-data partners nicely with ex-info 🙂

👍 5
seancorfield14:01:23

And now there's ex-message too.

Rachel Westmacott14:01:32

I’m so glad that people are talking about ex-*. More people need to know about it.

👍 20
jasonbell16:01:05

I actually managed to mention something about Clojure….. wow 🙂

👍 5
mccraigmccraig20:01:11

we use ex-data a lot... quite often the ex-data gets pr-strd into an http error response body