Before we can dive into the language syntax, we need to answer how to run code. Going into details about the various options is out of scope for this book. Instead, we will provide you with some pointers to various solutions.
The simplest way is to use the Julia REPL. This means starting the Julia executable (julia
or julia.exe
) and running code there. For example, we can start the Julia REPL and execute some code:
julia> x = 2
2
julia> x + 1
3
This works all very well, but what if we want to save the code that we wrote? To save our code, one can write “.jl” files such as “script.jl” and load these into Julia. Say, that “script.jl” contains:
x = 3
y = 4
We can load this into Julia:
julia> include("script.jl")
julia> y
4
Now the problem becomes that we would like Julia to re-read our script every time before executing code. This can be done via Revise.jl. Because compilation time in Julia is often long, Revise.jl
is a must-have for Julia development. For more information, see the Revise.jl
documentation or simply Google a bit if you have specific questions.
We are aware that Revise.jl
and the REPL requires some manual actions which aren’t super clearly documented. Luckily, there is Pluto.jl. Pluto.jl
automatically manages dependencies, runs code, and reacts to changes. For people who are new to programming, Pluto.jl
is by far the easiest way to get started. The main drawback of the package is that it is less suitable for larger projects.
Other options are to use Visual Studio Code with various Julia extensions or manage your own IDE. If you don’t know what an IDE is, but do want to manage large projects choose Visual Studio Code. If you do know what an IDE is, then you might like building your own IDE with Vim or Emacs and the REPL.
So, to summarize:
Pluto.jl