Nim New Project Template

Created: by Pradeep GowdaUpdated:Aug 01, 2024Tagged: nim · programming .

I noticed that friction to using different languages comes from not so much the differences in syntax, or even the ideas, but being productive in the environment of the language. The knowledge of one language’s build system (say python’s distutils/wheel/pip) to another (OCaml’s ocamlbuild/dune) is not exactly transferable. So the developer goes back to using their goldilock zone and doesn’t make progress in using the new language.

Nim is a language I would like to use more of. But, I always appear to get stuck when trying to use nimble to start a new project. I wanted to exercise writing a new project from start, but also make it easy for myself “not to think too much” when I wanted to start a small app or even a script next time. In Python, it is almost muscle memory now to use poetry to kickstart a project. For nim, there is a project template called nimptemplate that you can use to create a fresh project. I studied that project, and a couple of nim projects on github to figure out the necessary and common elements, and created a cookiecutter template that can be invoked like this:

cookiecutter https://github.com/btbytes/cookiecutter-nimproject.git

Cookiecutter then asks a few questions (project name, author, license) to generate a fresh project.

What I learnt about nim/nimble project setup from doing this: