polylith

itaied 2026-02-16T16:39:17.697469Z

when should an interface proxy the implementation as def and when as defn? in the realworld example i see both

(defn fetch-profile [auth-user username]
  (core/fetch-profile auth-user username))
and
(def env core/env)

seancorfield 2026-02-16T16:45:36.468269Z

"should" is subjective but I try to explicitly use defn for implementations that use defn and def for implementations that use def. And I provide user-facing docstrings for both. In the implementation, I provide developer-facing docstrings (about the implementation).

itaied 2026-02-16T16:58:03.218759Z

what is the rationale? i think i dont quite grasp the concept of interfaces in polylith i understand how it's useful to switch components in build-time (via deps) but it's just that the implementation doesn't actually know about the interface, so it leaves me a bit confused

seancorfield 2026-02-16T17:03:21.173359Z

This is what folks struggle with most when they first start learning about and using Polylith. The docs have been updated multiple times to try to explain it, but so far nothing seems to help much... First off, you don't have to have an implementation ns -- you can put the implementation in the interface file. The poly tool will check that all brick dependencies are done via the interface, so that allows a much cleaner separation between the interface and the implementation if you want (since the tool will error when you have a call directly into another components' implementation. That separation also allows for the docstrings to align with users for interfaces and developers for implementations, and for the interface functions to be in alphabetical order (or whatever specific order you want), whereas the implementation needs to follow Clojure conventions (definition before use, unless you use declare).

itaied 2026-02-16T17:18:54.022799Z

thank you for the clarification it makes sense when you look at it this way - expose the usage as an interface which is different from the implementation