Fork me on GitHub
#architecture
<
2018-01-29
>
dadair03:01:25

Any recommended resources for large-scale system design in clojure? Been using clojure for ~3 years, done mostly “small” web apps, but want to improve my design/organization skills.

dadair03:01:06

Could also be resources around large-scale FP design in general, would understand Haskell examples (for the most part)

seancorfield05:01:31

Have you seen Stuart Sierra' "Clojure in the Large" talk? That's a good "first step" in code organization.

dadair06:01:53

Yes, although I’m probably due for a rewatch. Also seen “component, just enough structure”, and have used component in my projects.

dadair06:01:55

My main concern is that I’ve never been exposed (personally, in a mentorship sense) to a more experienced clojure developer, and I am now in a position where I am the “experienced” clojure dev in a group of developers. Want to ensure I’m developing high quality clojure code so I don’t lead down an incorrect path.

seancorfield06:01:57

We have about 75,000 lines of Clojure. We've settled on a mono-repo approach with lots of subprojects for "libraries" and "servers" within that. We use Boot to manage that (with dependencies in deps.edn files -- that predate tools.deps) so we can build uberjars for any combination of subprojects.

seancorfield06:01:56

I think there are a lot of different ways of writing "good" Clojure but there's not much out there about namespace organization and general architecture "at scale" unfortunately...

yonatanel19:01:54

@dadair Generally I can recommend making your call stack as shallow as possible and having side effects like writing to db as close to the edges and up the call stack as possible (e.g at the end of a request handler not hidden in some deep function sandwiched between other side effects). It's not easy though.

seancorfield20:01:30

@yonatanel Yeah, I wrote a library (called Engine) that was meant to help with writing more "pure" code but we abandoned it after trying to use it for a while. It made for some odd-looking code. The idea was that you provided a hash map of data "sources" (things that are "queryable") and the library had update/insert functions that produced data structures describing the changes you wanted made, and then at the end you would "commit" them and the data structures would be walked and stuff written to "sinks" (things that are "committable").

seancorfield20:01:24

It was nice for testability -- no functions under test would do anything side-effect-y and you could easily supply mocked queryable sources, and then just assert the correct shape of the "change" data structures.

seancorfield20:01:57

But it was all a bit monadic in order to carry the sources and changes through all your code and that made things rather opaque at times.

seancorfield20:01:44

I still like the concept of it and if I can figure out a better implementation, I may well rewrite it...

yonatanel20:01:02

@seancorfield Don't you want to just use commands and events, maybe event sourcing?

seancorfield20:01:32

@yonatanel That's also an option to separate pure logic and side effects but it also has its pros and cons. Everything's a trade off 🙂