architecture

2018-01-29T03:01:25.000074Z

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.

2018-01-29T03:02:06.000147Z

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

seancorfield 2018-01-29T05:18:31.000152Z

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

2018-01-29T06:07:53.000144Z

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

2018-01-29T06:10:55.000207Z

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.

seancorfield 2018-01-29T06:11:57.000229Z

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.

seancorfield 2018-01-29T06:12:56.000048Z

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

2018-01-29T19:42:54.000519Z

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

seancorfield 2018-01-29T20:33:30.000294Z

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

seancorfield 2018-01-29T20:34:24.000093Z

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.

seancorfield 2018-01-29T20:34:57.000058Z

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.

seancorfield 2018-01-29T20:35:44.000429Z

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

2018-01-29T20:51:02.000413Z

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

seancorfield 2018-01-29T20:58:32.000747Z

@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 🙂