IDE and workflow tips for Julia.
The canonical sensible way to manage julia projects is given by Bogumił Kamiński’s:
For every project keep a separate project environment…The steps to achieve it are easy:
juliain the folder in which you want to create a project
]character to enter package manager mode
generate [target folder name]and press enter
You can activate such an environment with
Pkg.activate(".") or just use the jupyter IDE which does it automatically.
General tips: Look out for handy interactive introspection tricks, e.g. @which tells you which method your function invocation would invoke. There are other macros to tell you while file it comes from etc.
(v1.0) pkg> generate PatternMachine Generating project PatternMachine: PatternMachine/Project.toml PatternMachine/src/PatternMachine.jl (v1.0) pkg> activate PatternMachine julia> import PatternMachine [ Info: Precompiling PatternMachine [93e276e4-e6da-11e8-1ff8-9f9dfed081b5] (PatternMachine) pkg> add DSP
If you don’t want to manually invoke Revise to detect code updates, you can
use it automatically, which requires some version-dependent config in
(NB the vscode version is different.)
However, I do not do this since every project has startup overhead anyway, why not just put it in the config for a given project?
There is a package called Weave.jl
which is inspired by
knitr but compatible with
which is also not an IDE, but a good way of invoking reproducible
It could probably be used to fashion a working academic paper if you
used the right pandoc hacks.
NB you can also use RMarkdown in Julia mode It’s not clear to me how graphing works in this setup.
The most popular option seemed to be the default IDE, Juno, built on
I believe it is deprecated in favour of Julia for VS Code.
I sometimes use its julia features but often just edit code and execute it via the REPL or
IJulia without any special integration.
There is a degree of jupyter integration through
Each of these method has its own joys and frustrations.
Important: shortcuts to input unicode in julia seem to work across … everything?
A Pluto notebook is made up of small blocks of Julia code (cells) and together they form a reactive notebook. When you change a variable, Pluto automatically re-runs the cells that refer to it. Cells can even be placed in arbitrary order - intelligent syntax analysis figures out the dependencies between them and takes care of execution.
Cells can contain arbitrary Julia code, and you can use external libraries. >There are no code rewrites or wrappers, Pluto just looks at your code once before evaluation.
Your notebooks are saved as pure Julia files (sample), which you can then import as if you had been programming in a regular editor all along. You can also export your notebook with cell outputs as attractive HTML and PDF documents. By reordering cells and hiding code, you have full control over how you tell your story.
Neptune simplifies Pluto Neptune.jl: Simple (Pluto-based) non-reactive notebooks for Julia.
Neptune originated as a fork of the Notebook platform Pluto, for those (like Data Scientists) who have requirements which conflict with the 'reactive' aspect of Pluto (where all cells re-evaluate every time a single cell is evaluated or re-evaluated). It may turn out to be that Neptune is only an interim solution, and that the capabilities it enables will eventually exist within the Pluto, but that it is not certain. Users with projects or applications whcih are not logically sequential or linear in execution/design, or which do not load external scripts, should first try Pluto.
Writing a notebook is not just about writing the final document — Neptune empowers the experiments and discoveries that are essential to getting there.
I do not like it. Juno is single-window only so you can’t use multiple monitors, and thus you end up squinting at tiny windows of code hidden between all the outputs. Atom’s panes aren’t well-designed for this use-case. I find there are a million tiny frictions distracting me from writing code in Juno. This is not to diss the excellent work that the creators of Juno have done. It is a good product; I’m just not in the aesthetic target market.
If you install Juno as an app, but you also already use Jupyter, which you have already installed, there is an additional annoyance
in that it hijacks your Atom install in a confusing way and mangles your various package preferences.
If you love Juno and Atom, I recommend installing Juno from within atom
Possibly you can bypass this? I am not enthusiastic enough to work it out. Anyway, I do not really want to switch back to Atom. I finally got my VS Code setup just how I like it.
VS Code is my preferred editor for everything.
It has a
reasonably good julia extension
(although it is not good at resolving names in .
Because of Julia’s extended unicode support it is recommended to have a good
Insert Unicode and
Unicode Latex do the job.
IMO this is much smoother;
partly because VS Code is smoother than Atom, and partly because having my code in an external app is actually what I want most of the time.
If you do want your code running in your IDE, VS Code recently acquired an integrated debugger, and the ability to execute code in situ in modules which means you can update arbitrary parts of the source manually.
You can use jupyter with julia via IJulia. This isn’t an IDE er se, it’s a sort-of-light interactive notebook. I wouldn’t want to edit code in Julia; for that I use a code editor. There are loads of those. However, for presenting experiments and prototyping, this is a nice environment. These two components have a zippier and stabler workflow for my style, by not trying to do everything at once badly (which is what Juno seems to be all about.)
IJulia is also not flawless. For a start it uses Jupyter, which I don’t love.
It does not have debugger integration, so you cannot run Julia debuggers from it.
For another thing, it does overzealous installs per default, profligately installing another copy of jupyter, which you then have to maintain separately to the one you probably already had. Boring.
Here is how you fix that last problem:
tl;dr: For fish
conda create -n conda_jl python nomkl conda activate conda_jl env CONDA_JL_HOME="$HOME/miniconda3/envs/conda_jl" \ CONDA_JL_VERSION=3 \ PYTHON=(which python) \ JUPYTER=(which jupyter) \ julia # Now, in julia, run… using Pkg Pkg.add("IJulia") Pkg.resolve() Pkg.build()
conda create -n conda_jl python nomkl conda activate conda_jl CONDA_JL_HOME="$HOME/miniconda3/envs/conda_jl" \ CONDA_JL_VERSION=3 \ PYTHON=`which python` \ JUPYTER=`which jupyter` \ julia using Pkg Pkg.add("IJulia") Pkg.resolve() Pkg.build()
Taking that apart:
PyCall.jl invokes python. Per default it installs yet another conda python, via Conda.jl, and defaults to the elderly python 2.7. This is irritating for various reasons, such as being ancient, and eating your disk space with yet more versions of the same stuff that you already have installed in even more decrepit a state.
Here is how to use an existing version:
env PYTHON=(which python3) \ julia Pkg.build("PyCall")
Here is how you use Conda, but with python 3:
ENV["CONDA_JL_VERSION"] = "3" Pkg.build("Conda")
Here is how you use an existing environment
conda create -n conda_jl python export CONDA_JL_HOME=~/miniconda3/envs/conda_jl julia -e 'Pkg.build("Conda")'
conda clean -pt
You can bypass this by commanding it to use the perfectly good other jupyter:
ENV["JUPYTER"] = "/usr/local/bin/jupyter" Pkg.add("IJulia")
Now Julia appears as a normal kernel in your jupyter setup. (This is only exciting for habitual jupyter users and other anal retentives.)
If you want particular jupyter kernels for particular Julia environments, it is possible: by using the following kernel interpreter template:
julia -e 'import Pkg; Pkg.activate("myproject")' \ -L /path/to/kernel.jl
On Ubuntu a quirk of the build system sometimes requires
apt install libcairo2-dev
to avoid it demanding root permissions.
Apparently the IntelliJ Julia plugin is undergoing development. Keep an eye on it for me and let me know?