3
votes

I want to run a Julia script from window command line, but it seems everytime I run > Julia code.jl, a new instance of Julia is created and the initiation time (package loading, compiling?) is quite long.

Is there a way for me to skip this initiation time by running the script on the current REPL/Julia instance? (which usually saves me 50% of running time).

I am using Julia 1.0.

Thank you,

2

2 Answers

3
votes

You can use include:

julia> include("code.jl")
2
votes

There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:

In all the solutions you can send the command to Julia by executing some shell command.

No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.

As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.