Environments: My understanding
Julia appears to have been developed more as an “analysis” language than a language to develop end-user “applications”.
In other words, the intent is for users to launch Julia in a given “environment” that is appropriate for solving certain types of problems. Note that this environment is typically “interactive” (ex: REPL, Jupyter, Pluto, …).
Suggested Julia usage flow
I used to launch Julia from any old directory where my data and “scripts” were found.
Lately, I started ensuring these directories are actually “proper Julia environments”. The following is an example of how I might organize said environments:
/path/to/JuliaRunEnvironments
├─ GrammarOfGraphics
| └─ Project.toml
├─ CircuitDesign
| └─ Project.toml
└─ SatelliteImagery
└─ Project.toml
What do I consider to be a “proper Julia environment”?
- Quite simply, an environment is a folder that includes a “Project.toml” file appropriate for the analysis I am performing.
- In other words: an environment should include any/all the packages you might need for a particular analysis task.
Applying this methodology, you can mitigate conflicts where packages required in two different solution spaces might otherwise force certain dependencies to be downgraded. This is not possible if you are working in the default (@v1.6)
environment.
Regarding suggestions wrt the environment stack:
- Personally, I rarely push multiple
Project.toml
-based environments onto my environment stack.
- On startup of a new Julia session, I might make available a local library of custom packages using
push!(Base.LOAD_PATH, "/path/to/MyPackageRepo")
— but that’s about it.
- I prefer to keep my default/base
(@v1.6)
environment relatively clean/minimal to avoid issues.
Sample set of run environments
For illustration purposes, a developer might want the following set of what I would call “run” environments:
/path/to/JuliaRunEnvironments
├─ GrammarOfGraphics
| ├─ Project.toml
| ├─ ArtProjects
| | └─ starrynight_on_julia.jl
| | └─ monalisa_smiling.jl
| | └─ monalisa_frowning.jl
| └─ TestPatterns
| └─ nautilus_drawings.jl
| └─ fractal_trees.jl
├─ CircuitDesign
| ├─ Project.toml
| ├─ DeltaSigma
| | └─ 1_bit_dac.jl
| | └─ 8_bit_adc.jl
| └─ Filters
| └─ butterworth.jl
| └─ chebyshev.jl
└─ SatelliteImagery
├─ Project.toml
├─ MarsRover
| └─ detect_iron_concentration.jl
└─ Hubble
└─ compensate_for_gravity_lensing.jl
Seems to me like an ideal strategy to house domain-specific scripts.
So when do I ]dev
a package under development, exactly?
Typically only when I want to add/remove dependencies from said package.
Otherwise, I tend to create environments like:
/path/to/JuliaDevEnvironments
├─ MyPackageDev
| ├─ Project.toml
| └─ ...
└─ ...
which would, of course, include an appropriate Project.toml
file.
These environments are very light weight (basically one file). You just need to take a few extra steps to create them.
Then, when I wish to develop said package, I simply:
$ cd /path/to/JuliaDevEnvironments/MyPackageDev
$ julia
julia> ]
(@v1.6) pkg> activate .
(MyPackageDev) pkg>
julia> #Ready to start!