# IDEs for Julia

Usefulness: 🔧 🔧 🔧
Novelty: 💡
Uncertainty: 🤪 🤪
Incompleteness: 🚧 🚧

IDEs and workflow tips for Julia.

## 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 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
end
end
end

## IDEs/workbooks

There is a reasonable IDE called 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.

### Juno

Juno I think is the default. It has magical features - integrated debugger and, I am taold, automtic 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…

### IJulia

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. 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

### 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.