Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the "core" namespace nomenclature derive from?

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?

like image 464
maxcountryman Avatar asked Apr 07 '13 22:04

maxcountryman


1 Answers

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.

like image 184
Paul Legato Avatar answered Nov 06 '22 13:11

Paul Legato