IDEs for Julia


IDE and workflow tips for Julia.

The julia integrated development environment experience.

IDEs/workbooks

The most popular option seemed to be the default IDE, Juno, built on Atom. There is jupyter integration through IJulia. I personally just use VS Code to edit code but execute it via the REPL or IJulia.

All these methods have their own joys and frustrations. A nice summary is the one of doomphoenix-qxz:

There are two main IDEs in Julia, which are really plugins for Atom and VS Code. The plugin for Atom is called Juno; the plugin for VS Code is called Julia for VS Code. They're both really good and have nice autocomplete options, but if you want debugger support in the IDE, you want Juno. If you're like me, and you end up using two windows, one with your text editor and one with your Julia REPL, as your “IDE”, any text editor with autocomplete will do.

Update: VS Code recently acquired an integrated debugger.

Juno

Juno I think is the default. It has magical features - integrated debugger and, I am told, automatic substitution of LaTeX with actual unicode. Nice.

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 via the uber-juno package.

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

VS Code is my preferred editor for everything. It has a reasonably good julia extension (although it is not good at resolving names in includeed files). Because of Julia’s extended unicode support it is recommended to have a good unicode extension. 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.

Jupyter

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. (I use visual studio code.) However, for presenting experiments and prototyping, this is a nice environment. These two components have 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()

For bash

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")'

Either way you should regularly run conda clean to stop your disk filling up with obsolete versions of obscure dependencies for that package you tried out that one time. As per standard practice.

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.

Literate coding

There is a package called Weave.jl which is inspired by R’s knitr but compatible with jupyter, which is also not an IDE, but a good way of invoking reproducible self-documenting code. It could probably be used to fashion a working academic paper if you used the right pandoc hacks.

Pkg.add("Weave")

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.

IntelliJ

Apparently the IntelliJ Julia plugin is undergoing development. Keep an eye on it for me and let me know?

Workflow

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.

Use Revise.jl, and Project environments.

(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. To .julia/config/startup.jl add

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.