The Julia Community#
Especially in the modern world, a programming language is no better than the community resources it has on the internet.
Whilst the Julia community is smaller than that for Python and C++, it’s certainly well supported and active - and cross-fertilisation of ideas with other “newer” language communities such as Rust has led to a number of exciting developments as well.
Managing Julia Packages (Pkg)#
Julia integrates its own package manager with a module called Pkg
.
From within a Julia shell, it is easy to install packages with
using Pkg
Pkg.add("name-of-package")
as long as they’re known to the Julia ecosystem. Pkg will handle dependancies for any packages you install, and will usually precompile all of them to guarantee high performance.
Pkg also exposes many other verbs - build
(to precompile and re-setup packages), update
(to fetch package updates), rm
(to remove an installed package).
(Packages are registered in the Julia General Registry, and can be browsed with tools like Julia Packages )
It’s probably best to think of Pkg as similar to Cargo for Rust: it doesn’t just manage packages for your general Julia installation, it also manages the environment for a Julia project.
The activate
verb, with a directory path, causes Pkg to consider that directory as the root of a project or package, and manage packages relative to that.
Any package will have a “Project.toml” file which represents the dependencies and metadata for the project, which Pkg creates, as well as a “Manifest.toml” which represents the precise state of all packages installed (version and hashes), including dependencies of dependencies.
You will see that this repository has such files, showing the packages we need to import for the examples.
The Pkg “environment”#
Pkg is also one of two components of Julia which have their own sub-environments within the REPL (the other being the help functionality).
Pressing ]
in a Julia REPL switches to the Pkg environment, where all commands are issued to Pkg directly.
Hence
using Pkg
Pkg.add("foo")
is the same as
add foo
within the Pkg sub environment.
Pressing backspace on an empty prompt exits the environment and returns to Julia proper.
Loading modules#
Once you have modules installed locally, Julia provides a familiar way to load their symbols into the namespace.
using packagename
loads all of the symbols from packagename into the namespace, with no qualifiers. So, if packagename
contains an exported function called foo
, we can use it as
foo() #the "foo" from "packagename"
Conversely, to load a module but keep symbols from it in their own namespace, use import
:
import packagename
packagename.foo() #"foo" is in its own namespace
Both functionalities support loading more than one module at once with a comma-separated list. They also allow specific symbols to be loaded from a module by naming them after a colon (:
), and using the as
keyword to rename individual symbols, or the name of the module’s namespace.
So:
using packagename: foo as pnfoo #only load the symbol "foo" into the global namespace from "packagename", and rename it to "pnfoo"
import packagename as pn #add the symbols in "packagename" as the "pn" namespace
(If you load two packages into the namespace with conflicting symbols - say, two modules that both export “plot” - then you will need to explicitly disambiguate with the module name when referring to those symbols.)
IJulia#
As Julia is one of the core Jupyter languages, it is easy to set up a Jupyter environment once you have a Julia install, with the IJulia package. With the help of the Pkg module, we can simply type
using Pkg
Pkg.add("IJulia")
using IJulia
If you want to launch a notebook from within Julia itself, you can then simply type
notebook()
to launch your Jupyter notebook service. IJulia will prompt you to install and set up a local MiniConda instance for Jupyter if you want to be truly standalone, otherwise you can integrate with your existing Jupyter install.
Getting Help with Julia#
The Julia community is generally friendly and enthusiastic. As with any modern community, it lives at various places on the Internet.
“Forum Style” - the Julia Discourse#
The extensive Julia Discourse ( https://discourse.julialang.org/ ) serves as the centre of much of the Julia community’s long-term communication.
“Real Time” - the Julia Slack [and others]#
For real-time conversations, the most popular instance is the Julia Slack ( https://julialang.org/slack/ ), although there are also communities on both Zulip and Discord.
HEP specific - the JuliaHEP subgroup#
For the last several years, the community of HEP people using Julia has had its own centre on the internet, based around https://www.juliahep.org/ . (There are also subchannels on the main Julia Discourse and Slack devoted to HEP.)