julia> @time using Plots
12.731850 seconds (17.25 M allocations: 976.326 MiB, 3.64% gc time)
julia> @time using DifferentialEquations
34.780873 seconds (41.90 M allocations: 2.456 GiB, 2.63% gc time)
julia> @time using Atom
3.137487 seconds (2.95 M allocations: 184.199 MiB, 1.27% gc time)
This makes Julia nearly unusable. Does anyone know why Julia is so much slower here than other languages and does anyone know if this will ever be fixed?
I thought julia wanted to be faster, not slower than Python.
On 1.6 (not yet released) I’m getting 2.6 and 4.5 seconds for Plots and DifferentialEquations. So this is still not perfect, but is much better than 1.5.3. 1.6 should be out soonish (December or January)
This is a well-known problem, and there have been dozens of commits to address the root issue. As a result, there’ve been significant improvements since v1.4:
julia> @time using DifferentialEquations # v1.4
42.003165 seconds (70.47 M allocations: 3.891 GiB, 3.65% gc time)
julia> @time using DifferentialEquations # v1.6
10.538916 seconds (14.14 M allocations: 1.121 GiB, 4.64% gc time, 27.26% compilation time)
Package loading times are being actively worked on as others have mentioned.
If you care about startup time instead of runtime, then indeed you should use Python. If you later decide you want to do something with those packages after you load them, Julia will be waiting for you.
There are a couple reasons for this. The first is that Julia needs to do some compilation when you load packages. This is necessary because any package can add methods to functions that change how other functions perform. The good news is that this is expected to continue to speed up (there are already ideas for how to make 1.7 faster than 1.6 currently is).
Large modules can take several seconds to load because executing all of the statements in a module often involves compiling a large amount of code.
In simplified terms, Julia is a compiled language while Python is an interpreted language (the reality is much more complicated than that). If you really want to understand why, you’re going to have to invest some time in learning about how Julia and Python work under the hood. A thorough answer to your question would be quite long.
I know that Julia is compiled, but I did not know that it needs to be (partly) recompiled every time you relaunch julia, because of what Oscar_Smith said:
This is necessary because any package can add methods to functions that change how other functions perform.
With a sysimage I managed to get the startup time to usuable speeds. I know that many people don’t care for startup time, but I can’t use the REPL, because I haven’t found any IDE workflow that is acceptable.
Thank you.
(But if you are at the point of making lots of files, you should probably be creating modules and doing structured programming, and then calling your modules from your notebooks. In fact, with NBInclude you can actually use notebook files as part of your Julia modules if you want, but personally I would tend to use notebooks only for interactive exploration code and keep long-term code in modules.)
Jupyter notebook can’t work with *.jl files, but all libraries are *.jl files
include and import work just fine, as does Revise.jl for interactively running code as you edit modules.
Or do you mean that notebooks can’t be used to edit.jl files? I thought we were talking about REPL replacements here and interactive work? If you want an IDE or an editor, use vsCode or JupyterLab or …
I’m confused about whether you are talking about writing “libraries” (modules/packages) or about writing interactive scripts.
Backtraces will not show the correct file number
Backtraces should work fine in notebooks. For statements in the running notebook, they will give you line numbers like In[35]: line 15, i.e. line 15 of input cell In[35].
Check jupytext, you can use a .jl file as a notebook. That is super usefull for version control too.
Also in vscode you can have a similar interacting experience using the Shift + Enter workflow and separating each peace of code you wants to run (“cell”) between ##s directly in a .jl file