Julia’s Package Manager Is AWESOME | by Emmett Boudreau | Towards Data Science

In the past, I’ve gone beyond praise for the amazing multi-paradigm statistical language, Julia. This is for good reason because Julia is an incredibly high-level language that stretches the limits of what we thought could come from such high-level syntax. Additionally, in terms of being ideal for machine-learning, from how much I’ve used the big four, Julia is perfectly able to out-perform Python, R, and even Scala. I even briefly joked about getting a Julia tattoo on my head, even going as far as to create a semi-realistic rendering of that exact thing:
Looks great, doesn’t it?
But with all of this flaunting of one of my absolute favorite programming languages of all time, I’ve much neglected one of the features that makes Julia even better:
Pkg
Pkg is Julia’s package manager, and it is not a typical package manager like the ones you would find in Python or R. In fact, for the most part, I firmly believe that Julia’s package manager outmatches every Linux package manager I've ever used, including Dnf, Apt, Man, and likely the most robust: Pacman. There are a few key benefits that make managing packages in Julia a breeze with the Pkg package manager, and it’s likely that you’ll say
“ It can do that?” at some point.
A massive benefit to Pkg is that it has its own read evaluate print loop, or REPL. This is beneficial for a few reasons, the first of which I would like to mention is that it can add packages quicker than the library equivalent. This is because it makes it possible to skip recompiling a stale cache file entirely simply by pressing a key,
]
Additionally, this allows for non-syntactual package adding, making it super quick and easy to add a package with simply a command and a space:
add "Lathe"
In addition to having a REPL, however, Julia’s Pkg also comes in the form of a Julia package itself. This is useful because it means that you can not only add packages from within the REPL, but also the code itself. This was particularly useful whenever I created TopLoader, which is a Python package that allows you to create a virtual Pkg environment and then use the packages added to that environment.
Julia’s package manager is entirely based off of Github, where packages are pushed into the Registrator.jl repository, which you can take a gander at here.
Not only does this make it incredibly easy to push your Julia packages through Github, but also allows you to add unregistered packages with Git URLs. This makes unpublished software, which is usually stored in a Git-compatible repository always usable. Julia’s packages use Github as a foundation for development, and that is certainly not a bad idea, as even non-developers are well aware that Open-Source development essentially revolves around Github.
There are a lot of questions in life that have yet to be answered, but the age-old question of
“ Who did environments the best?”
has certainly already been answered. Compared to Pip, Package get, Quick Lisp, and the thousands of other package managers that are also called “ Pkg,” Julia’s Pkg once again outshines the competition. From the get-go, out of the box you can activate a virtual environment with two simple commands from the REPL, or a method from the package.
using PkgPkg.activate("venv")julia> ]pkg> activate "venv"
This makes managing and utilizing these virtual environments shockingly easy. It’s hard to justify this methodology of activating virtual environments without comparing it to a similar option of one of Julia’s competitors, Python. The package manager for Python is Pip, and though certainly not quite as robust as Pkg, I think Pip certainly stands the test of time and gets the job done in Python. But to activate a virtual environment for Pip, you need to install an entirely new package, that being venv, or something similar (there are a few different options.)
sudo pip3 install virtualenvpython3 python3 -m venv venvname
This is certainly not terrible, but on the other hand: certainly not nearly as robust and simple as the Julia equivalent. Reiterating on my Python package for loading Julia modules in a virtual environment, development of said package was incredibly easy because I was able to use the activate() method.
I love Julia’s Pkg, and I tip my hat to the developers that put in the hard work to develop it, only to make the Julia programming experience that much better. I think many other package managers have a lot to learn from Pkg, because to me personally, it has always felt like the perfect package manager. I encourage you to try it out, as it feels like a breath of fresh air in a world filled with CLI package managers. Overall, I think that Pkg.jl contributes a lot to Julia, and makes the language even more enjoyable than it already is (hard to do) to use.