Hacker News new | ask | show | jobs
by Capricorn2481 1090 days ago
Let me tell you, I've been diving back into it and it's just the same stuff. It took me a pretty long time just to get logging working. I had to Grok Integrant again because I wouldn't understand my project otherwise. And when it comes to best practices around unit testing, it's another one of those things where no one in the community seems to be sharing much about it. I used Kit to bootstrap this project and the way it set up tests doesn't even work, but this was what most people recommended to me for starting a Clojure project

I think the vibe I have gotten working for so long in Clojure is that you're basically screwed unless you are already in a work place using it.

1 comments

> I had to Grok Integrant again because I wouldn't understand my project otherwise.

You can use plain functions and `reduce` for system composition if you want. Take a look at how Biff does it: https://biffweb.com/p/thinking-about-system-composition/

DI should be used sparingly for the top-level, stateful pieces of your system. If you can't understand your program without it, is this a problem with Clojure itself or the design of the program?

> And when it comes to best practices around unit testing, it's another one of those things where no one in the community seems to be sharing much about it.

The `clojure.test` API has stayed the same for the last decade and that's what you'll see in most projects. Is the concern about how to run tests? Both of the following libraries work well:

- Minimal test runner: https://github.com/cognitect-labs/test-runner

- Full-featured test runner: https://github.com/lambdaisland/kaocha

If you install neil (https://github.com/babashka/neil), you can do `neil add test` which will automatically set up cognitect-labs/test-runner in your project. Then you can run tests with `neil test` (just an alias, you don't have to use it).

> I used Kit to bootstrap this project and the way it set up tests doesn't even work, but this was what most people recommended to me for starting a Clojure project

I don't really like the approach that Kit takes and prefer something more opinionated like Biff. I'd love to hear your feedback if you do end up trying out Biff.