Fork me on GitHub
#clojure-uk
<
2020-08-26
>
seancorfield04:08:17

Mornin' Happy Hump Day!

dharrigan05:08:28

Good Morning!

thomas09:08:18

I have just merged the 3rd PR for my MQTT broker. Someone is actually looking at my code.

👍 9
thomas09:08:32

And improving is, but that isn't that hard 🙂

Jakob Durstberger10:08:51

Very nice, do you have a link to the repo?

thomas11:08:26

it is a MQTT server (and client to some degree)

thomas11:08:33

and uses spec for testing

dharrigan15:08:40

sigh I know not many people here have use of Spring, but I use it quite a bit at work (with my Kotlin adventures). It's okay...until you have to step out of it's walled garden, then it's back to writing reams of code and figuring out the load order of the beans and whether any are being ignored/replaced by your stuff.

dharrigan15:08:36

What is super simple in Clojure, having a few jdbc connections to a few databases, is non-trivial to do with Spring

Ben Hammond16:08:07

what are you trying to do with Spring?

Ben Hammond16:08:57

I mostly liked it in a > It doesn't often make me do things I don't want to do kind of way

Ben Hammond16:08:10

but that was back on version 2.5.6 Maybe Its Changed

mccraigmccraig16:08:32

what does it do that makes having a few jdbc connections hard @dharrigan?

Ben Hammond16:08:57

going off piste with Hibernate - now that is hardcore

Ben Hammond16:08:06

and you don't have to use Spring? Just do it in plain old java

mccraigmccraig16:08:57

i seem to recall using it back in the day, getting rid of the xml frontend and replacing it with a jruby frontend, and it was quite nice then... but we were moving a mostly java system over to ruby/jruby, so that kinda sorta made sense for us

dharrigan16:08:33

Well, I'm using JOOQ which is a nice DSL for SQL, you run it against your schema and it generates type-safe classes etc.. Then you can use a fluent DSL to construct your SQL queries. It's supports in Spring Boot for a while now.

dharrigan16:08:52

It gives me control of precisely crafting the SQL to send to the DB.

dharrigan16:08:07

But, Spring Boot, is very opinionated. It assumes just one JDBC connection.

dharrigan16:08:26

which covers the majority of cases I suppose.

dharrigan16:08:59

So, if you want to have another DB connection to another database, to then merge in data from two different databases, you have to construct your own DSLContext

dharrigan16:08:23

but, there's this magic "@ConditionalOnMissingBean" on the JooqAutoConfigure on Spring Boot

dharrigan16:08:49

if you try to define your own dsl context, it won't create the default one.

dharrigan16:08:59

so you have to create both or N-many dsl contexts yourself

dharrigan16:08:14

with all the ceremony that comes with that.

dharrigan16:08:58

was a lot easier using next.jdbc 🙂

Ben Hammond16:08:04

So you step off the happy path and suddenly you have to grok how the component parts are bolted together

Ben Hammond16:08:40

And suddenly you are contemplating a very steep learning curve

Ben Hammond16:08:23

Yeah from that point of view I'd agree with you

Ben Hammond16:08:58

Clojure has a pretty steep learning curve too of course

dharrigan17:08:42

Yeah,I'm off the deep end 🙂

dharrigan17:08:59

The thing, however, with Clojure, is that it has only a few constructs, and the libraries are generally well thought out (i.e., next.jdbc). I can see in front of me how things work and the layer(s) are thin. With Spring, it works really well and it's fantastic for quickly getting something out (for the business that is!) but with lots of magic stuff happening behind the scenes (lots of proxying and annotations), it's all hidden from you, so if you do need to do something a bit different, then you have to delve very deep to see what is going on, then surface again for some air to pretty much DIY.

dharrigan17:08:45

It feels more natural, more what-it-means-to-be-a-programmer, using Clojure with some libraries, than Spring 🙂

👍 3
dharrigan17:08:26

If I can channel Dr McCoy for a moment..."I'm a programmer, not a Spring developer dammit" 🙂

😂 3
seancorfield17:08:16

In the early days, clojure.java.jdbc (nee clojure.contrib.sql) used a single dynamic Var for the DB connection so it was almost impossible to use with multiple connections/multiple databases too 🙂

dharrigan17:08:54

glad that's changed 🙂

seancorfield17:08:29

It was a very nasty set of breaking changes. I would handle it very differently today.

seancorfield17:08:08

(I think I made breaking API changes in three releases as I worked on c.j.j)

dharrigan19:08:59

You know one of the other attractions that I have with Clojure, is it's data oriented approach - just maps, vectors and lists (and a few scalars). It makes shuffling data in and out of a database via an API (which goes on the wire as JSON) so refreshingly easy and simple to do.

mccraigmccraig21:08:44

yeah, data orientation is definitely one of clojure's superpowers

mccraigmccraig21:08:43

every time i have to do some data manipulation in java or js i cry a little

👍 3