Environments, Projects and Packages
Julia has three closely related terms which are "environments", "projects" and "packages". Let's go over what these terms mean.
In the following sections of this tutorial series, we’ll discuss what we need to know about how to organize a project.
This includes organizing code into modules and different files, creating a test suite, automatically generating documentation, and more, like compiling packages and collaborating on open-source packages.
Before we begin, let’s go over some basic terminology.
Environments
The most simple of these three concepts is the “environment”.
An environment is just the way for Julia to know what “import X” or “using X” means.
In order to do this, an environment defines a set of packages as dependencies, optionally with versions down to specific commits.
Reasons to use different environments include the ability to work with different package versions, like older ones for backward compatibility, or switching between stable and development branches of code.
Projects
A project, on the other hand, is the way by which we organize our work. In particular, a project necessarily defines and environment (i.e. a set of dependencies) but it also has other things, most commonly:
src
directory with the main body of code.test
directory for testing the project functionality.docs
directory with documentation files.
Packages
Finally, a package is largely a project that has been made public, for others to use as a third party library.
As such, a package should focus on reusable code, and avoid certain things we might have when we have a project for personal use, like global runtime configuration parameters, or contain a collection of “scripts” that run code.
Other way of understanding the difference in the Projects/Packages terminology is by considering some close analogues of both terms: For example, we can also think of Projects/Packages as Programs/Libraries, correspondingly. A useful distinction is that projects are usually top-level code, while packages are reusable code.
Importantly, a package should contain a project file with a uuid
, or unique identifier, which is used to identify the package in projects that depend on it.
Conclusion
When I just started programming in Julia, I found these terms a little confusing, as sometimes they are used interchangely. I hope this post provided some clarification.
For a more in depth description of these, and other related terms, you can check out the Pkg documentation Glossary