IDE and workflow tips for Julia.
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 Revise automatically:
atreplinit() do repl try @eval using Pkg haskey(Pkg.installed(), "Revise") || @eval Pkg.add("Revise") catch end try @eval using Revise @async Revise.wait_steal_repl_backend() catch end end
and (they claim) that to
Julia/config/startup_ijulia.jl you must add
try @eval using Revise catch end
But for me this leads to the kernel hanging shortly after startup, and the non-IJulia setup is sufficient.
For VS code users
.julia/config/startup.jl should purportedly be
atreplinit() do REPL @schedule begin sleep(0.1) try @eval using Revise catch err warn("Could not load Revise.") end end end
See also Erik Engheim’s workflow walk-through.
All these methods have their own joys and frustrations.
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. For me that means there are a million tiny frictions distracting me from writing code in Juno. I can’t stand it.
If you install Juno as an app, but you also already use Jupyter,
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 using homebrew? I didn’t try. But maybe give this a burl:
brew cask install juno
I personally don’t find juno worth the irritations, and never use it. Instead…
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.
IJulia isn’t an IDE er se, it’s a sort-of-light interactive notebook. I don’t want to edit code in Julia; for that I use a text editor. There are loads of those. (I use visual studio code.) However, for presenting experiments and prototyping this is good. These two components have have a less annoying, zippier and more stable workflow for my style by not trying to do everything badly, which is what Juno seems to me to be all about.
A serious plus for the jupyter option is that if you wish to share your results with colleagues you can use juliabox, an simple online julia host.
IJulia is also not flawless. For a start, it’s built on Jupyter, which I don’t love.
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.
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 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 diskspace 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 this sometimes requires
apt install libcairo2-dev
to avoid it demanding root permissions.
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.
See also Literate.jl for some similar functionality.
Apparently the ItnelliJ Julia plugin is undergoing hot development. Keep an eye on it?