I'm relatively new to Clojure but I've noticed many projects implement a "core" namespace; e.g. foobar.core
seems to be a very common pattern. What's the history behind this and why is it the de facto standard?
It's just a generic name that represents the "core" functionality of something. The core functions of Clojure itself define a general purpose programming language, with very generic functions you might need in many different problem domains. Functions which are only applicable to a specific problem domain go into domain-specific namespaces, such as clojure.string
or clojure.set
.
Tools like Leiningen can't know a priori what sort of a program you're trying to write, so they set you up with a foo/core
namespace by default, modelled after clojure.core
-- clojure.core
is the core functionality of Clojure, so foo.core is the core functionality of foo.
If you can give your core namespace a less generic name, or just use foo/core
to kick off bootstrapping (such as by holding your -main
function), that's encouraged, so that the bulk of your code will reside in more semantically meaningful namespaces instead. This helps you find the specific code you want to work on later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With