Why do Many Clojure Projects Have a "core" Namespace?



"core" namespaces in Clojure are annoying!

Project Names and "core" Namespaces in Clojure    

Almost every Clojure project seems to have a core namespace. This is something that lein new project-name creates, and people just go with the flow.

I don't like this, and it turns out I'm not the only one. See Where does the "core" namespace nomenclature derive from? for some discussion.

Leiningen does different things depending on the type of name you give it. I can't make a lot of sense of this, but here's what my playing has revealed (with Leiningen 2.7.1).

A Simple Name

(This is what most people seem to do.)

lein new simple-name

  • Creates a directory named simple-name with a project named simple-name.

  • Creates namespaces named simple-name.core and simple-name.core-test.

If you do this, please immediately delete the namespaces and then create other ones with better names.

A reverse-domain-name/name -Style Name

(I think I plan to mostly do this in future.)

lein new com.backwards.domain/my-name

  • Creates a directory named my-name with a project named com.backwards.domain/my-name.

  • Creates namespaces named com.backwards.domain.my-name and com.backwards.domain.my-name-test.

An x.y Name

lein new foo.bar

  • Creates a directory named foo.bar with a project named foo.bar.

  • Creates namespaces named foo.bar and foo.bar-test.