I am new to Julia and I am using vscode with the Julia extension to run code. Unfortunately, Julia responds incredibly slow. Outputs into the terminal take 7-8 seconds every time I run this simple script.
a = 2
b = 3
c = a + b
print(c)
Why does it take so long and what can I do to solve this? If I use Julia directly in the terminal it responds very fast, but obviously, I need to run scripts.
This simple script definitely shouldn’t take long to run. In my case, if I execute your simple script line by line, the first line takes about 2 seconds to show up and get executed. All the following lines are executed “instantaneously”.
First time startup of the Julia REPL in VSCode takes some time because it first has to precompile some dependencies for VSCode itself and for Revise. Try to run the script twice in a row without closing the terminal in VSCode. Does the second run also take as long as the first run?
I run the code via the run “run file” button. I am not sure what happens in the background. So I dont know if the extension closes the terminal. The second start does not differ noticible from the first one.
Ctrl + Enter will execute the current line or selection (i.e. “send line to REPL”). Shift + Enter will execute a code block which you can create by adding ## where you want a block to end (i.e. “send code block to REPL”).
You can look these commands up if you open the keyboard shortcut reference (Ctrl + K Ctrl + S) and search for Julia.
The “Run File” button currently starts a new Julia process each time it’s used. I’d recommend using the Julia: Execute File command instead, which reuses the current Julia REPL.
Is there any way to run an already executed (and thus compiled file) from REPL, so that it doesn’t get compile again? Sorry, I could not understand how to use “Julia: Execute File” command.