One-namespace minilibs - and are libraries meaningless at the code-level?

I just wanted a bit of a sanity check… b/c I’ve managed to confuse myself a bit

Do libraries have any significance at the code level?

When I say libraries, I mean the stuff you put into the deps.edn file… Is it safe to treat a library as effectively a bundle of namespaces? As far as I can see, post jack-in (or launch process) this becomes opaque from the code perspective.

Furthermore it seems in-code the library’s name is irrelevant - and there isn’t really anything forcing you to use the same name between library and its namespaces

Lately I’ve been really trying to modularize and reuse my code more - so I’ve made about a dozen one-namespace libraries and I’ve been placing them in flat folders with just…

myLibA/deps.edn
mylibA/mylibA.clj
{:deps
 {caninputanythinghere {:local/root
                        pathToLib}
  cooldude/fancyLib    {:mvn/version
                        "1.1.1"}
  :paths
  ["."]
  }
(ns mylibA) ;; no period separated stuff..
;; my code

The weird part is that for a local library the library name is a meaningless value. (never declared or used anywhere subsequently) …

The whole setup seems to work very well so far. It has helped me modularize my codebase and dependency graph a ton. I reuse the pieces in different scripts and applications. However I don’t see anyone else doing this… so I feel I must be missing something. How will this come back to haunt me?

A library is just a collection of resources along with a declaration of its own dependencies. .clj or .class files are just resources as well - JVM uses classloaders to look up the right resource and load it when asked.

Regarding modularization - I haven’t tried it myself but perhaps you’ll find GitHub - polyfy/polylith: A tool used to develop Polylith based architectures in Clojure. interesting. And just as an example of what you’re already doing - GitHub - juxt/edge: A Clojure application foundation from JUXT.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.