The Problem with Julia that makes me want to leave - First run Times

I started my programming journey in Python. A year ago, to create a real-time simulation, I came to know about Julia with its great speed.
I used Julia for the first time and I remember the spark of joy I had while messing around with natively available heavy math functions. Julia was fast. I converted my custom Python functions in Julia and it was orders of magnitude faster.

But for some reason I used Manim (Makie/Plots/Javis/Luxor just aren’t as flourished), switching back to Python for a while. And… honestly, I felt relieved not to wait for a minute or two each time I open the code editor. Relieved for not having to wait for my functions to be compiled. I would just open my PC, get to work, test things and I’ll be done!

This brings me thinking about a few things. Julia, although there is this discourse, has a lack of community. The Manim discord had people helping out EVERY second. No joke. There were always people just helping you.

Julia has a GREAT community too. I’ve had many people help me. Greatly! But it just isn’t as good as Python. Which is obvious. But, although it’s an open secret, Julia’s first run time straight up sucks! Gosh! If only Julia didn’t have that would it be the BEST language!

No doubt, to have an efficient project, Julia is better. But if you just wanna test things out, the run time takes away the fun. Once the code compiles, the results are instantaneous. But really, this is perhaps one of the reasons Julia wouldn’t make it in the vast community. The language is the God’s gift for the long run. But for quick tasks, I would prefer to use Python or some other language (And it really hurts).

Any updates on the first run times? Anything that we can do about them?

6 Likes

Hi!
On which julia version are you?
Since 1.9 startup times improved a lot.
Waiting a minute when opening the editor or loading a package seems a bit excessive.
But it’s true that python startup and load times is still faster than julia’s

5 Likes

If you manage, as of Julia 1.9, to isolate your work in specific environments (see this for example), with current code cashing that pain can be significantly reduced. Yet, not perfect. I have a hard time using Makie, for example, still, because of that.

Concerning instantaneous help, you can get that kind of feedback in the Slack or Zulip Juila channels.

(and you won´t find anything as developed as Manin in Julia, afaik, so probably for that using python is just the right choice)

1 Like

There is some ambiguity of language around time-to-first-<x>. Here is the status as far as I’m aware:

  1. Start REPL with nothing loaded: For me it takes about 7 seconds. Not snappy, but not a huge blocker for me at least. Edit: I have a number of packages loaded in my startup.jl which slows me down. Others have indicated that the relp actually takes less than a second to load.
  2. Install a package in an environment: As of 1.9, this does take longer to install a package because we have to do precompilation. But at least for my use cases, this PALES in comparison to installing Pandas, for example.
  3. Loading a package: As of 1.9, this is a touch slower because it now has to load all the previously precompiled machine code into memory.
  4. Running a package’s function: This is MUCH faster now. Previously, it would need to compile the function on first run everytime. Now, it can go to the precompiled code for most use cases. This is the area where we’ve seen huge gains in TTFX.
  5. Compiling user functions: I haven’t experienced any of my user code taking very long to compile as long as the package functions I’m calling are sufficiently covered by precompile statements.

In 1.10 and 1.11, there are refinements and improvements to the process for machine code caching, most important of which is parallizing precomilation.

13 Likes

7 seconds? What do you have in your startup.jl? For me it is a fraction of a second.

13 Likes

Oh, good point – yeah, I do load a number of dev packages in my startup.jl!

4 Likes

You can do:

julia -O0

Julia compiles, and by default uses optimization level 2; 1 would also be an option. even --compile=min (I though all of this though outdated advice). Compile times are a less of an issue now in e.g. version 1.10 (with precompiled packages), but note optimization is always a tradeoff, when you actually have to wait for compile times. It always slows down compilation, and you may pay it at runtime (when for non-package code, or in case they get recompiled).

Python is often described as interpreted, but it’s actually compiled too (to bytecode), just not optimized as much. And since Python 3.13 alpha, has experimental JIT.

It doesn’t have to be either or. I hadn’t heard of Manim, but you can use any plotting solution with Julia, look up PythonCall.jl, and the examples are for other Python plotting packages, but should translate. I.e. you basically use Manim docs and discord and those people can help with anything. And Julia people with Julia specific stuff. And you get the fast startup of any Python package (basically they are written in C and fully precompiled, why fast to start, not because of Python).

Julia doesn’t have to suck, even for startup, at least with Python…

1 Like

Using an environment where CairoMakie is installed, this is what you can currently get to create a figure:

% time julia --project -e "using CairoMakie; v = rand(10,2); plt = scatter(v[:,1], v[:,2], rasterize = true, markersize = 30.0); save(\"test.png\", plt)"

real	0m2,992s
user	0m3,076s
sys	0m1,063s

That’s actually pretty good, if one is more or less careful in not stacking a lot of packages together, the environments can become quite stable and be very responsive. But sometimes adding a new package to the environment can certainly lead to new painful recompilations.

6 Likes

Also take a look at GitHub - jolin-io/JuliaScript.jl: finally fast julia scripts

9 Likes

If I have a time-to-first-run of more than 5s, then I create a custom system image…

Yes, this creates some extra effort, but for the tasks I am working with (DifferentialEquations, Makie, ModellingToolkit) it is worth it…

With newer versions of Julia this is less and less often needed (luckily)…

2 Likes

All right here’s an example.
I’m not saying that the first run times are awful… in fact yes, there are good loading times. Running my fully-fledged code takes a bit longer but yeah, it’s not longer than a minute or two. In Python, however, the entire thing barely took 5 seconds to boot up (although the computation was slower). Just that it takes away the fun and switching back to Python, the difference was immediately noticeable.
PS: the packages in the environment were GLMakie, GeometryBasics and Plots with Julia 1.9.4 (tbh… surprised with the speed, they did reduce the FRT with the update!)

Yep… 1.9.4. And while they have improved upon the first run times, python is miles ahead. Regardless, once the Julia code is compiled, it’s light years ahead lol.

The difference between the user experience lies when you just gotta walk a mile. While Python does it instantly, Julia takes time to load. And for tasks that already require a fraction of a second to compute, the advantage Julia has doesn’t matter. Where it DOES matter is when you have some heavy, large computation. And for that, Julia is the best!

Yep, am running an isolated environment. And while that helps, you’re correct it still pales in comparison to other languages.

If only I wished Julia had fully fledged packages for “on-the-go BEAUTIFUL plotting… not just plotting for the sake of plotting”.
Also… SOMETHING FOR GAMEDEV! Julia can do so well with that (except again the loadspeeds lol)!

1 Like

Happy to know!

1 Like

I do prefer to run the code natively lol… but hey! Thank you for the advice! I’ll check that out!

Why so long? On my Macbook M2, REPL with Revise and OhMyREPL loaded launches in much less than 1 second.

5 Likes

But you said “with nothing loaded”… Will you please modify your original post to reflect this important addition?

2 Likes

Did you try to create a custom system image? If not, why not?

Do you create custom system images for your work?

If so, what was the experience like? How often do you feel compelled to update packages and rebuild?

If not, why not?

2 Likes

you can try also to update to 1.10, it should be faster