Here are some tips for working with Julia efficiently.
As already elaborated in The Julia REPL, Julia's REPL provides rich functionality that facilitates an efficient interactive workflow. Here are some tips that might further enhance your experience at the command line.
A basic editor/REPL workflow
The most basic Julia workflows involve using a text editor in conjunction with the
julia command line. A common pattern includes the following elements:
Put code under development in a temporary module. Create a file, say
Tmp.jl, and include within it
module Tmp export say_hello say_hello() = println("Hello!") # your other definitions here end
Put your test code in another file. Create another file, say
tst.jl, which looks like
include("Tmp.jl") import .Tmp # using .Tmp # we can use `using` to bring the exported symbols in `Tmp` into our namespace Tmp.say_hello() # say_hello() # your other test code here
and includes tests for the contents of
Tmp. Alternatively, you can wrap the contents of your test file in a module, as
module Tst include("Tmp.jl") import .Tmp #using .Tmp Tmp.say_hello() # say_hello() # your other test code here end
The advantage is that your testing code is now contained in a module and does not use the global scope in
Mainfor definitions, which is a bit more tidy.
tst.jlfile in the Julia REPL with
Lather. Rinse. Repeat. Explore ideas at the
juliacommand prompt. Save good ideas in
tst.jl. To execute
tst.jlafter it has been changed, just
It is also possible to interact with a Julia REPL in the browser via IJulia. See the package home for details.