News for hackers. Stuff that matters.
Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @07:01AM (#38516233)
Going all in is precisely the point.

The biggest selling point of Julia is that it's as easy to write as python if you don't care about performance, and if you do care about performance it's as fast as C++ if you can just follow some simple principles. This actually works in practice. For my day job I write the slow path exactly as I would python, and that's a really fast way to write code.

If you want a slow language that can call fast code, you already have python.

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @07:30AM (#38516464)
Biggest selling point of Julia is that you're locked in to Julia if you use it?

For me this is the biggest point for giving up on Julia. Julia has a lot going for it in the basic design and I was really excited about it in the beginning.

But even after all these years the environment is sadly almost unusable if you want to do something saner than REPL/notebook.

The TTFP is too damn high and I don't think it will ever be fixed.

Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @07:58AM (#38516685)
> environment is sadly almost unusable if you want to do something saner than REPL/notebook

I work in "one of those industries" where failure can easily cost millions in the space of minutes, and we use Julia almost exclusively. Unfortunately I can't give you details because of reasons, other than tell you you're very poorly informed.

> you're locked in to Julia

You're not "locked in" to Julia any more you're locked in to Python. Arguably less, as Julia can call C natively, Python can't.

My point isn't that you can't interop, and it seems you're intentionally (?) equivocating on this point. Surely you didn't misinterpret what I wrote as "you can't iterop"? My point is that you can more benefits if you don't. Like I said, if you want a slow language that can call fast routines, why not just use Python.

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @08:26AM (#38516916)
Python can call C natively. Also Python programs can be used as CLI tools interacting with practically any language. Julia programs in practice can't.

But I know from experience that this debate will not go anywhere. It's is the same old refusal to see the problem: "you're using it wrong".

Julia is dying and this is why it will die.

Re:Potential of the Julia programming language for high ener... by th0ma5 on Monday December 04, 2023 @03:10PM (#38522402)
Yes, this is so true. There is a lot of wild attacking of the questioners of Julia.
Re:Potential of the Julia programming language for high ener... by ykonstant on Monday December 04, 2023 @08:47AM (#38517135)
>I work in "one of those industries" where failure can easily cost millions in the space of minutes, and we use Julia almost exclusively. Unfortunately I can't give you details because of reasons, other than tell you you're very poorly informed.

I vaguely recall a post from an ex Julia dev who had raised some issues regarding correctness of computations in Julia; I am not very familiar with the situation, have these concerns been addressed?

Edit: now that I recall better, I think the correctness concerns had to do with ambiguous composition of disparate components due to vague interfaces. I think this has to do with multiple dispatch in Julia, but I don't know details. I would love any info about this.

Re:Potential of the Julia programming language for high ener... by lukego on Monday December 04, 2023 @12:00PM (#38519759)
My impression is that this comes down to expectations.

You might have a function:

foo(x,y) = x + y

and multiple dispatch means you can call that with integers, or floats, or arrays, or GPU-resident arrays, or automatically-differentiating numbers, or symbolic algebra terms, or...

Just because you can, does that mean you should? It depends...

Re:Potential of the Julia programming language for high ener... by kelipso on Monday December 04, 2023 @12:46PM (#38520395)
I think it was more like you have a function over an abstract type like:

foo(x::Number) = x+1

And then someone else creates a new type thats a subtype of Number. And they run foo(x) and get errors or unexpected output.

Problem is the new type they created doesn't follow the assumptions that foo expects. Throw multiple dispatch into the mix and it gets even harder.

Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @12:56PM (#38520541)
> foo(x::Number) = x+1

> Problem is the new type they created doesn't follow the assumptions that foo expects.

If you define that function and someone else (i.e. a user of your lib) defines a subtype of Number and calls your function on it, and it fails, then they haven't respected the interface to Number. There's nothing wrong with that function or type specialization in that case. In that case it's all about defining useful interfaces and respecting, as much of programming is.

E.g. if someone defines a subtype of Number because he has something that's kind of like a number in some respects but not others, maybe that shouldn't be an subtype of Number.

You also shouldn't define functions that have obscure conditions for being properly useable - at least if you expect your code to be useful more broadly. Nothing here is specific to Julia though.

If you have other specific examples we could discuss more.

Re:Potential of the Julia programming language for high ener... by mcabbott on Monday December 04, 2023 @02:10PM (#38521643)

    using Unitful: m; foo(2.0m)
With the above definition, this will give DimensionError: 2.0 m and 1.0 are not dimensionally compatible.

Probably this means you should define `foo(x::Number) = x + oneunit(x)` to respect the Number interface. But this interface isn't very strictly defined. I believe `Base.oneunit` was added after someone started writing the Unitful package -- building something useful in a legal grey area, and formalising later?

Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @04:27PM (#38523358)
Interesting case! Lets discuss.

I don't know/use Unitful, but if that function didn't fail it's because the guys who wrote Unitful defined a promotion rule from Int to their Unit thingy. So.... that's how their type works. Don't use it. Or better, open an issue on github, they might have an explanation that's escaping us. I suspect it has to do with their mental model of what Unitful is supposed to achieve.

Let me tell you that my intuition agrees with you. As an ex-physicist, if I was designing a lib called Unitful I wouldn't let you sum sum 1 meter plus 1 unitless thing.

EDIT:

Actually, I just tried running your code and I do get DimensionError

    foo(2.0m)
    ERROR: DimensionError: 2.0 m and 1.0 are not dimensionally compatible.
I'm guessing you have some seriously outdated versions of something?

EDIT2: Sorry I misread you. You do get an error. Ok I see your point. Maybe the Julia docs should more explicit about what the Number interface entails. Is `+ 1` allowed? You're assuming the answer is obvious, but it's not to me. In particular, that's not generic at all. You're probably right about `+ oneunit(T)`

Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @09:38AM (#38517790)
> I think the correctness concerns had to do with ambiguous composition of disparate components due to vague interfaces. I think this has to do with multiple dispatch in Julia

You'd have to be more specific. Currently ambiguous dispatch throws an exception. I don't think this is a recent change either.

Re:Potential of the Julia programming language for high ener... by leephillips on Monday December 04, 2023 @09:03AM (#38517308)
Yes.
Re:Potential of the Julia programming language for high ener... by amj7e on Monday December 04, 2023 @01:29PM (#38521030)
HFT? :D

Which country are you in?

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @08:22AM (#38516883)
What do you mean by TTFP? Is this like "time to first byte"? If so, what is the "P"?

In any case, if the complaint is startup time, I do agree that this has been a bit of a thorn in the side. It also interacts poorly with a (in my view) pretty immature ecosystem for running services (for instance, the grpc library doesn't seem to be widely used or heavily maintained) or interacting with it via IPC. So it's great if you can spin up a notebook or repl and leave it running all day doing your work, or if you have a long-running batch process, but I agree that I've found it a bit tricky to interact with it from the outside world in the "usual" ways.

Having said that, it does work - for instance, a system I work on spins up a long-lived julia thread from within a python service using the very nice shared library, and calls into julia functionality through that thread - I've just found it to be tricky; but IMO still very much worth it.

Re:Potential of the Julia programming language for high ener... by cyber_kinetist on Monday December 04, 2023 @08:36AM (#38517010)
> What do you mean by TTFP?

Time To First Plot. It was a meme back then that you needed to wait several minutes to draw just a simple line plot after starting up a Julia REPL/notebook because of compilation times (whereas in Python you're done in seconds with matplotlib.) Seems this has been reduced in Julia 1.9 with automatic pre-compilation of packages, but plotting still isn't "instant" as you would expect in scripting languages like Python.

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @09:46AM (#38517910)
For many complaints TTFP is not about REPL or notebook. It's about how long it takes for a new Julia process to do the plot.

TTFP is (close to) solved. 1.9.0 TTFP is under 3 seconds for me, which I find about acceptable for script-type workflow. However, time-to-first-DynamicalSystems is still around 10 seconds, which is not.

Re:Potential of the Julia programming language for high ener... by ChrisRackauckas on Monday December 04, 2023 @07:10PM (#38525207)
Loading new Julia processes takes long because the standard library is rather large. One big part of v1.10 has been the excision of more standard libraries out of the the core image. This required some of the v1.9 and v1.10 improvements because things like `using Pkg` was practically instant as a result of Pkg being in the system image, and thus moving these out of the base system image without a major regression required all of the package binaries infrastructure. The ecosystem is now getting ready for this change with recently all packages now requiring the versioning of standard libraries, standard libraries are now versioned independent of Julia and can do their own releases, so they are very close to be standalone. I'm not sure the progress with this in v1.11 but I think the intention was fto make it so that things like Pkg do not load with the start of Julia. The big elephant in the room there is then for BLAS to not load until `using LinearAlgebra`. The majority of the startup time is just spinning up BLAS threads the last time I checked, and with all of these other changes in place we should be ready to test this removal.
Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @08:25PM (#38525815)
Useful info!! This is sort of a lazy-web thing, but do you know where this work is being organized or how one might start contributing to it?
Re:Potential of the Julia programming language for high ener... by sundarurfriend on Tuesday December 05, 2023 @02:25AM (#38528002)
I don't think there's a central organizing place, the work is happening across several Github issues and PRs. There's the Internals subforum [1] on Discourse if you have questions or need guidance, and there's a #internals channel on the Slack too.

[1] https://discourse.julialang.org/c/dev/5

Re:Potential of the Julia programming language for high ener... by sgt101 on Monday December 04, 2023 @08:45AM (#38517111)
It seems instant to me - the package compile on first invocation is rather like installing with pip or conda, and then after that I see the plot in about 1/20th second.
Re:Potential of the Julia programming language for high ener... by leephillips on Monday December 04, 2023 @09:06AM (#38517350)
The REPL starts up instantly and the first plot is < 1s. People seem to be repeating complaints (valid at the time) that they overheard from three years ago.
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @09:42AM (#38517857)
This is not the complaint. The complaint is that running "$ julia someplotting.jl" takes a long time (actually with 1.9.0 it's reasonable at < 3s, but adding other libraries makes it easily tens of seconds or even minutes).

Everybody doesn't use the REPL. In my, I think quite well founded, opinion nobody should use the REPL for more than one or two lines.

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @10:00AM (#38518073)
For what it's worth, as someone who shares a sense that "scientific" programmers have a tendency to over-use notebooks and REPLs, I find your perspective on it to be too extreme in the other direction! It's perfectly possible to incorporate interactive tools into a good software development process.
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @11:13AM (#38519050)
I don't mean that running in Bash should be THE workflow. But I think it should be supported and it's used widely and lack of support for it is a major reason why Julia is not taking off. I'm not proposing taking REPL/stateful-notebook away from those who want to use it (although I'll advise them against it if asked).

I don't find my plt.plot(x,y); plt.show() in a script ideal either. Something like Pluto.jl (given it's easy to modularize and preferably can be run without a notebook environment) is most likely better for a typical data analysis workflow (and will likely lead to more reproducible results and better tracking of result provenance).

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @11:20AM (#38519167)
But there isn't "lack of support" for running cli scripts, there's just a few seconds of startup time (or less than that; it depends a lot on what dependencies the project has, in my experience). Like, I don't want to diminish that this amount of latency matters, but I just feel like you're being hyperbolic. I've used tools with more startup time for most of my career - the jvm, ruby when running any non-trivial rails app, essentially every ahead-of-time compiled language, etc. - it's not a good thing, and all those tools have invested massively in improving their startup times because of that, but I just really don't see how it can be considered a deal-breaker... (And for what it's worth, most non-trivial python codebases I work with also spend a ton of time starting up, though this can be fixed with investment into it.)
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @12:19PM (#38520044)
Especially for data analysis the latency is crucial. I run the code practically on every time I change a line. It's not that different from how people run REPLs, but I just keep the lines in files that I run. Would people be just fine if each REPL line would have tens of seconds of latency overhead?

For different cases, e.g. application development, the latency is not that critical. Although I find it quite insane that we accept so slow code iterations this day and age.

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @03:12PM (#38522433)
Again, I'm not trying to downplay how much it matters, I just think you're being pretty hyperbolic about it! You've said stuff like it's "impossible" and "not supported", and I think these are just way stronger than "very inconvenient" or "extremely frustrating". Maybe it's a minor point, I dunno, but like, if we were talking about a five minute compile cycle or a language that doesn't even have a way to run a script at the command line, then sure, I'd agree with what you're saying, but as it is, it just feels a bit like a tempest in a teapot to me...
Re:Potential of the Julia programming language for high ener... by ChrisRackauckas on Monday December 04, 2023 @07:12PM (#38525227)
Indeed it's something in the middle. For data analysis, many people are used to using RStudio and just keeping a running REPL going, and Julia works quite well for these kinds of tasks in the same mode because that effectively removes the startup time from being a concern. However, there are some folks that are used to other workflows and we could grow the audience by improving the ability to support such workflows better.
Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @08:30PM (#38525864)
For what it's worth, my workflow is actually much closer to the parent's; I have a python batch job that spins up a julia runtime in a thread at startup and waits on a `Pkg.instantiate()` of a project with pretty substantial dependencies before it can start sending method calls into it. I think it takes like 3-5 seconds to start up. I badly want it to be a lot faster than that, but it's also fine. I'm not happy with it, but if I sat here thinking about it for a few minutes, I'm certain I could list a hundred things in our system that annoy me more than this.
Re:Potential of the Julia programming language for high ener... by jampekka on Tuesday December 05, 2023 @09:44AM (#38531425)
That's probably something close to DaemonMode.jl?

If the problem was just running a daemon, it would be an inconvenience at worst. The problem is that changes to the code tend to trigger a recompile, can't be made (e.g. structs can't be redefined if I recall correctly) and most crucially the session can get "silently" into some unexpected confused state.

If you don't need to change the code (and it's structured well enough not to hold a state between calls), then running in a process is no problem. But for that you can do just plain old AOT.

Aside from my personal gripes, which I have probably aired here more than enough for everybody, I think the design that more or less forces REPL/notebook style is detrimental to quality of scientific code. Scientists don't learn to modularize their code and don't learn to understand the basic control flow. I see this all the time with my colleagues and the "pedagogical problem" of notebooks/REPL is very common when I teach programming. E.g. a common problem is that students don't understand variable assignment because with REPL/notebook it doesn't necessarily follow the normal program flow.

I'm kind of amazed how little the scientific programming scene is concerned about this. From software development perspective (I'm an ex software developer turned scientist) having clearly defined state transitions, independent modules of code and the code doing what it says are really really fundamental things, without which you have no chance in hell in making anything more than a few lines to not turn into an unmanageable and buggy mess.

Maybe there's a (mis)conception that scientific code is somehow fundamental different beast than "general programming". But it's not. It's just a relic of having bad systems languages like C and C++ and bad special purpose languages like MATLAB and R. That Python can be and is used for both is an existence proof that there is no such divide. But we need a better Python for both general and scientific programming.

Re:Potential of the Julia programming language for high ener... by sanderjd on Tuesday December 05, 2023 @01:51PM (#38535269)
> Aside from my personal gripes, which I have probably aired here more than enough for everybody, I think the design that more or less forces REPL/notebook style is detrimental to quality of scientific code.

So, two things here: First of all, I have greatly appreciated the discussion, so don't feel like you've over-aired your thoughts!

But also, here's this, in my view, hyperbole again, I just don't see how "more or less forces" is the right way to describe the state of choosing whether or not to use a notebook/REPL style for julia. It works perfectly fine to develop with a different style. There's a little bit of startup time, but it's just not nearly a big enough deal to say it "forces" a different development process.

I think your criticisms of notebook driven programming make sense, but are also slightly overblown; in my experience, scientists are perfectly capable of writing good modular code, despite preferring to work in notebooks most of the time. It's not not a problem, I just don't think it's been a very big problem, in my experience.

But I very much agree with your last two paragraphs. I just don't think notebooks / REPLs are a big part of the reason things have ended up this way. I think it's more of a cultural thing that gets passed down from generation to generation, and it has to do with respect; I think scientists have never taught one another that code deserves respect and professionalism. I think they have always thought of it as "some throwaway stuff that generates the data for the paper"; the paper is the thing deserving of respect, not the tools used to create it.

But I think this has been slowly changing as more and more scientists are digitally native and learn increasingly more software skills as a first class concern.

Re:Potential of the Julia programming language for high ener... by jampekka on Thursday December 07, 2023 @07:04AM (#38555467)
Agree that I may be hyperbolical at times and this can be detrimental to fruitful discussion. I'll be more mindful of it, thanks!

More accurate is that the REPL/notebook style is currently so much more convenient to get started and to "explore" with that people will use that and it's what all Julia examples etc teach. Pluto.jl may be a good "transition" from this though, although I'm afraid modularization is still too inconvenient with it.

The script-workflow latency is also a reason why "scripters" don't switch to Julia even though they otherwise would.

So while the it's not practically impossible as I hyperboled, it is IMHO a blocker for wider Julia adoption and a transition to better programming practices.

In my experience in both teaching and helping working scientists with their code problems I think the current situation that REPL/notebook is so much easier to get started with is at least a major reason why better practices don't get adopted.

Scientists themselves doing any programming is quite a recent thing. Usually it was "lab engineers" doing "the coding" and data mangling and the scientist doing "the analysis" in something like SPSS or Excel or copypasted R oneliners.

It's also really understandable why scientists don't make much effort to learn and enforce good programming. It's a relatively minor part of their job, they manage to scrape much of the analysis together with poor practices, and when it almost inevitably explodes as the analysis gets more complicated, someone "more technical" gets called to fix the mess (I do this all the time).

In most languages modularizing code is made needlessly hard, and I'm smelling something like this in Julia module system (and in e.g. Python packaging). I sometimes wonder if there's some (unconscious) gatekeeping to keep "the using" and "the programming" (and "the core development") apart artificially. You actually sometimes encounter explicit statements like this (Linus Torvalds famously about C++ but in this post's discussion something like that not knowing R means that you shouldn't use ML (which is extra bizarre because very very few actually know R)).

The benefits of modularization are also not easy to foresee until you learn from many hard lessons of ending up with unmanageable sphagetti or analysis that is wrong but it may be even impossible to pin out why due to lack of reproducible code. And if you don't know about the ways of avoiding/mitigating this, you're not really equipped with learning the lesson.

When this compounds with significant hurdles to do "the right thing" I find it almost inevitable that "the right thing" will not get adopted.

As a sidenote I find it also quite odd why so little effort is done to "show the work" with data analysis when it's literally required when you do it in math class. I think they are almost the same thing. Maybe it stems from the computer seen as a calculator and "the work" is done on paper, but this is mostly due cultural lag from the era where computers were in practice calculators.

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @08:30AM (#38516937)
Time to first plot (this is the time you have to wait for any plot if you don't do REPL/notebook in analyses). It's a commonly used term in Julia discussions.

Nowadays also called TTFX where X can refer to variety of things.

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @08:35AM (#38517003)
Ah thanks! I'm relatively new to Julia and don't frequent discussion forums (yet?) and didn't have much luck searching for it. I figured out that it was an X in TTFX, but thought maybe, "print"?

In any case, yep, makes sense, thanks!

I guess for the typical scientific experimentation with plotting use case, why not just use the repl / notebook approach that (I think?) doesn't really suffer from this issue, as it's already up and running? My experience with startup time being problematic is when trying to "productionize" things that are not within a scientific / plotting loop. But my impression has been that it works well when doing things that are. Am I missing it?

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @09:39AM (#38517811)
The main problem with REPL/notebook approach is that it has an "invisible state". E.g. running the cells in different order or running the same line in REPL twice can cause different behavior. This leads to major issues in e.g. reproducibility, easily introduces bugs that even leave no trace and generally it's very much against very core software development principles. Pluto.jl reportedly solves this, gotta try it out.

My scientific/plotting loop runs from Bash (something not solved by Pluto.jl). This allows me to interoperate with a lot of software that's not in Python. I can version the code with e.g. git and the analysis pipeline tends to get refactored into libraries and CLI tools in the process. With Julia this is in practice impossible.

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @09:55AM (#38518015)
I definitely don't think "impossible" seems like the right word. I do buy that it might be frustratingly slow to the point of not being worthwhile.

I do wonder if Pluto.jl might solve a lot of these issues for you though. I haven't really used it much, but it seems like it works with just plain .jl files, so you can non-jankily version them (unlike .ipynb), and extract libraries and refactor in all the normal ways.

My frustrations trying to do normal-software-development-principles with julia are actually more about the convention the community has around structuring files and modules, which just hasn't clicked for me at all and is a frequent source of confusion. (The testing framework / layout / something about it also hasn't clicked for me yet either, and I wonder if it just isn't great and that's why people don't seem to write many tests...)

But there's also just so much great stuff about the language that I'm not even really mad about any of this :)

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @10:47AM (#38518686)
> I definitely don't think "impossible" seems like the right word. I do buy that it might be frustratingly slow to the point of not being worthwhile.

That is more accurate.

> I do wonder if Pluto.jl might solve a lot of these issues for you though. I haven't really used it much, but it seems like it works with just plain .jl files, so you can non-jankily version them (unlike .ipynb), and extract libraries and refactor in all the normal ways.

It may solve enough issues at least for some cases. I'll check it out.

> My frustrations trying to do normal-software-development-principles with julia are actually more about the convention the community has around structuring files and modules, which just hasn't clicked for me at all and is a frequent source of confusion. (The testing framework / layout / something about it also hasn't clicked for me yet either, and I wonder if it just isn't great and that's why people don't seem to write many tests...)

From what I remember from the last time the module system was indeed quite a pain. The using/include/use seems like a total mess, and that IIRC Stefan Karpinski dismissed files-as-modules solely on the reason that Python does it that way did not really bring my hopes up.

I appreciate that the multiple dispatch design (which I find very much a pro for Julia) does bring about some additional challenges for a module system. But my hunch is that majority is because Julia was so strongly made by MATLABists to MATLABists (can replace MATLAB with e.g. R or Mathematica) that basic features required for a general purpose language were not much taken into account.

> But there's also just so much great stuff about the language that I'm not even really mad about any of this :)

This is exactly why I'm so mad about this! I would love to use all that great stuff AND follow good programming principles, but now I can't.

Re:Potential of the Julia programming language for high ener... by sanderjd on Monday December 04, 2023 @10:58AM (#38518844)
Yeah, maybe I'm just not jaded enough yet, but all the issues I've seen seem relatively superficial and solvable to me. It feels more like immaturity pains than fatal flaws to me. But it's not so young anymore, so maybe the immaturity is more insurmountable than it seems to me. I dunno!
Re:Potential of the Julia programming language for high ener... by sgt101 on Monday December 04, 2023 @08:33AM (#38516973)
>The TTFP is too damn high and I don't think it will ever be fixed.

I just installed and ran on my macbook - took me 7 minutes to get it installed and run through to a first plot, most of that was installing and compiling the Plots library.

Once it's installed and available I can run it in about 1 second and then execute

using Plots

function test_plot()

x = range(0, 10, length=100)

y = sin.(x)

plot(x, y)

end

@time test_plot()

which gives me a result of 0.048700s and a nice plot.

I don't think this is the defining issue with Julia now - it definitely used to be 10 years ago - but now it's more than competitive with Python in this regard.

The issue is really support and buy in for all the new cool libraries that folks make available to use.

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @09:18AM (#38517523)
That's not TTFP. TTFP is putting that code into a file (e.g. ttfp.jl) and running:

$ time ./julia-1.9.4/bin/julia ttfp.jl

0.325806 seconds (202.80 k allocations: 13.208 MiB, 84.23% compilation time)

real 0m2.401s user 0m2.357s sys 0m0.553s

I.e. the TTFP is 2.4 seconds, not 0.33 seconds.

That said, 2.4s is huge progress (e.g. with Julia 1.6.0 it's 10 seconds for me) and acceptable for most simple plotting.

But just adding e.g. "using DynamicalSystems" brings this to 14 seconds, which is not acceptable for iterative editing. And it makes any Julia program using "DynamicalSystems" wildly impractical to use in a pipeline with other programs.

Re:Potential of the Julia programming language for high ener... by adgjlsfhk1 on Monday December 04, 2023 @09:39AM (#38517810)
Also for the record, 1.10 rc1 brings the time down to 1.1 seconds (from 1.9 seconds in version 1.9 on my laptop). There's still more work to do, but there's been a ton of progress on this in the last year or so.
Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @09:42AM (#38517860)
No point having this conversation. These people are still repeating memes from 5 years ago. I've met one of them in the wild, it was quite eye opening.
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @10:03AM (#38518104)
You are probably having a different conversation. This is my conversation:

$ time ./julia-1.10.0-rc2/bin/julia -e "using Plots; using DynamicalSystems;"

0m5.433s

This is a different conversation from

julia> @time plot(x, y)

  0.000465 seconds (484 allocations: 45.992 KiB)
But I agree that the conversation is pointless. The TTFX will never be fixed for Julia to be used with sane workflows because the few still using Julia don't want to accept the problem. But the flamewars are fun anyhow and maybe they prevent the next Julia from making the same mistakes.
Re:Potential of the Julia programming language for high ener... by adgjlsfhk1 on Monday December 04, 2023 @11:12AM (#38519041)
I think this conversation is absolutely worth having. It's great to see that 1.10 is ~3x faster here, and there's probably another ~2 to 3x improvement or so from profiling DynamicalSystems to see where the time is going. That said, for sub second startup time with lots of packages, I highly recommend using PackageCompiler to make a custom system image which brings the using time down to roughly 0.
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @12:05PM (#38519845)
Is shaving seconds-per-package import a feasible way to get the startup time fast enough for script-type workflows? Before long you end up importing 10 packages and it will be too slow even if each package is 1s. I appreciate that the devs seem to want to do it "the right way" but that seems have taken quite a while.

Wouldn't something like slow interpreter option for "glue code" be feasible? Most code doesn't need to be fast, and waiting for the "hot functions" to compile on change wouldn't be too bad. And you could still AOT for maximum speed when needed. This is essentially how Javascript JITs manage to start up so fast.

Another fine "hack" for many cases would be to keep the Julia process running (like a daemon) but making sure the state is clean when a script is run on it.

Something like PackageCompiler is workable, at least for the short term. Long compiles are OK if they don't have to be done all the time. I indeed manage to get < 1s TTFP with DynamicalSystems with it (last time I tried a while ago I didn't manage). The UX for creating sysimages could be nicer, but doesn't seem anything that a quick script can't fix. Maybe I'll give Julia another go in my next analysis.

From what I gather there's now a new approach for caching the compilation results. I really hope it will succeed, but I'm a bit jaded from the many "Julia 1.x fixes the TTFX" news.

Re:Potential of the Julia programming language for high ener... by sgt101 on Monday December 04, 2023 @12:23PM (#38520109)
Ahh I getcha a bit. What is the usecase though - which script-type workflows? (genuine curiosity, not just asking!)
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @12:52PM (#38520483)
Typically modeling timeseries data and comparing it to data collected from humans (e.g. car telemetry, motion tracking or eye tracking signals). The models are stochastic dynamical systems which have to be optimized against the data. It's more or less exactly in Julia's niche.

The script typically loads the data files and runs simulations (a lot of times when their parameters are optimized). This means the models have to be fast, but they are also recurrent in nature so they can't be vectorized to numpy. So depending on the case it's usually numba, cython or C++, all of which can be quite painful.

Re:Potential of the Julia programming language for high ener... by sgt101 on Monday December 04, 2023 @01:17PM (#38520828)
So what you are saying is that you would like a process that was live - with everything loaded, and ready to respond to any code that you wanted it to run, as opposed to having to bring up a new Juila process for each step in the pipeline.

Can't you compile the pipeline into a single script and then run it in a single instance of whatever?

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @02:32PM (#38521952)
I want the opposite. To have different processes for each step. Potentially the different steps being in different languages.

Or at least semantics of that. The steps should be independently callable and each call should result in the same output with same parameters, i.e. the state would reset for each run. I don't care so much how this is exactly implemented as long as it fullfills these.

The data doesn't need to stay in the process memory. It's can be e.g. mmapped and is cached by the OS anyway. And deserializing tens or even hundreds of megabytes takes usually less time than Julia takes to import Plots.

This is the thing that isn't feasible with Julia due to the TTFP (each step incurs the startup latency).

Re:Potential of the Julia programming language for high ener... by ChrisRackauckas on Monday December 04, 2023 @07:02PM (#38525142)
The next step is to enable more post-invalidation precompile for Plots. This is something we recently setup with Symbolics.jl since that is another package which has some "invalidation by design" patterns, where certain assumptions made in the compiler (such as (x==y)::Bool) are invalidated by symbolic numbers acting differently than a lot of numbers and thus some over-eager optimizations require being removed upon using. PrecompileTools.@recompile_invalidations is a recent (v1.9 era) tool that allows for forcing the compile at package precompile time to consider the environment post-invalidation and thus re-precompile, effectively reducing the TTFX in these cases where invalidation is always going to occur by design. Plots.jl is a case like this because its recipe system is effectively allowing people to extend the plotting pipeline well after Plots is loaded, which is its main killer feature but effectively means that one should expect invalidations from it. I think that recompilation post invalidation should make a strong dent in that and plan to see if that's the case in a few months when I get the time to dive in.

> Wouldn't something like slow interpreter option for "glue code" be feasible? Most code doesn't need to be fast, and waiting for the "hot functions" to compile on change wouldn't be too bad. And you could still AOT for maximum speed when needed. This is essentially how Javascript JITs manage to start up so fast.

That is something I've been meaning to investigate more. A lot of the Plots.jl code is internally dynamic because of its design to hold everything in a Dict{Any} and recurse the plot recipes. In other words, it doesn't even benefit from having the JIT at all because internally everything is uninferred boxed variables. There's probably a good way to just do "please interpret the calls in this part of the pipeline" and not see any runtime difference but chop out the core of the compilation. It's relatively straightforward to do, it's a one liner using JuliaInterpreter.jl @interpret, and I think one dig that results in a win would be a nice example of what should be a pattern we do more often in the near future.

Re:Potential of the Julia programming language for high ener... by jampekka on Tuesday December 05, 2023 @10:47AM (#38532380)
I did briefly look at JuliaInterpreter.jl and if something like that can be used for general purpose, the TTFX would be fixed, the complaints would stop and I'd wager Julia would gain a lot in popularity. I really hope it happens.

For now the interpreter seems to focus on debugging, and if I understand correctly, it can't be really used to e.g. speed up imports or to specify hot code to be AOT'd/JITed?

Re:Potential of the Julia programming language for high ener... by sgt101 on Monday December 04, 2023 @12:21PM (#38520068)
I mean DynamicalSystems is big - 183 subpackages... it doesn't surprise me that it requires some time to pull it in and make it available to other code.. what's the design choice that they should have made that would avoid this?
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @02:52PM (#38522242)
E.g. javascript can have thousands of subpackages/dependencies and it starts up instantly. Scipy is huge but importing it is practically instant. "Classic" AOT can take ages to compile, but it doesn't have to compile on every run.

JS does this by multi-phase JIT. Python by being dog slow in the execution and AOT by being dog slow in the compilation.

I think Julia's "JIT-AOT" may be a good approach (and perhaps almost necessary for Julia's dispatch) too but it seems to be very hard to make start up fast.

Re:Potential of the Julia programming language for high ener... by ChrisRackauckas on Monday December 04, 2023 @06:51PM (#38525014)
It can be improved though. Part of the issue is my fault and I plan to redo the DiffEq solver defaulting mechanism in order to reduce the amount that needs to precompile. The design of how to do it is already pretty clear and it's mostly about having the time to do the grunt work. I hoped to get it up last month but had a bit too much travel, but it shouldn't go beyond January. After that's up I plan to reassess some of the profiles for what the remaining pieces are and post some future plans for specifically this part of the ecosystem, but for now the ball is in my court and I need to make some improvements here.
Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @11:35AM (#38519397)
You're building pipelines for someone else. I'm using the pipeline someone else built.
Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @12:08PM (#38519886)
I'm building pipelines for myself to use. The result is often pipelines that other people can use too. It's all just code, there's nothing magical in building pipelines.
Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @12:57PM (#38520567)
I would love to see something you've built.

Do you have anything that you've shared publicly?

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @01:28PM (#38521010)
Here's an example: https://github.com/jampekka/vddfit

Codewise it's not pretty, especially the data mangling, but other people have managed to use it for their own purposes.

The model had to be implemented in C++ and wrapped for python bindings. It's a pain but sadly less painful than doing it with Julia's startup time.

Re:Potential of the Julia programming language for high ener... by sertbdfgbnfgsd on Monday December 04, 2023 @05:11PM (#38523883)
Blast from the past from my days in the academia.

Ok thanks for sharing.

(I still disagree about everything you said about Julia though. I bet you I could re-implement this faster in Julia thank your C++, and in a type generic way too which would make it trivial for users to plug in their types, and it would be trivial to package - I'm assuming you didn't package that repo, you just expect your users to be shuffling files around. You're not contributing to improving the reproducibility situation in the academia, let me tell you xD)

Re:Potential of the Julia programming language for high ener... by jampekka on Monday December 04, 2023 @05:56PM (#38524346)
So the handful of _Julia users_ with their totally unreproducible REPL mess can "trivially" plug in their types? Also saying the horrible mess that is Julia's module system is "trivial to package" is delusional.

I didn't package it and the data mangling part has very little use outside this specific experimental design. Also Python's packaging is quite shitty.

The C++ code is totally standalone and can be git-pulled and compiled how you like. C++ packaging is totally abysmal.

As I said in the comment and the README the code is a mess (although a piece of art compared to the notebook shit out there). It's purpose is that the results can be reproduced from the raw data.

I would love to make my analysis code cleaner. But there's zero incentive for that and very little time. Nobody sadly cares about the code, and most scientists can't code for shit. This is probably why Julia was designed so that it forces your code to be shit.

Sorry but the tone, but you kinda set it.

Re:Potential of the Julia programming language for high ener... by cozzyd on Tuesday December 05, 2023 @01:13AM (#38527656)
So I tried this after I installed julia on my system (Fedora) and installed the Plots package. It took about a second or so, not too bad, slower than ROOT or matplotlib but not too different from octave... but the default backend is not interactively zoomable at all as far as I can tell? Ok, I can do Pkg.add("PyPlot") to use matplotlib, but now this takes an extra ~10 seconds? It would probably have been faster to mmap a shared file, dump the data there, then, fork a new python process and plot it... maybe I try the plotly backend (which doesn't need any new packages, that's nice), but now it opens in my browser? By now my .julia directory has balloned to 2.8 GB (!!!) and I'm bored of this test and go back to making my quick plots in ROOT :).

edit: oops, maybe PythonPlot is what i should use, not PyPlot. But when I try that I see: ┌ Warning: `PythonPlot` 1.0.3 is not compatible with this version of `Plots`. The declared compatibility is 1 - 1.0.2.[ and doesn't seem to be any faster

Re:Potential of the Julia programming language for high ener... by cozzyd on Monday December 04, 2023 @12:13PM (#38519970)
Nobody is going to implement an important library in Julia that other things rely on if everything that relies on it must be reimplemented in Julia too.