7 comments

  • ekjhgkejhgk 19 hours ago ago

    This is so exciting.

    Julia's multiple dispatch is really powerful. In my opinion it's great user experience for implementing generic code.

    It has a downside: since you don't know at build-time what types you'll shove inside your functions, you don't know what to compile.

    But some times the user does know. What does this, according to my understanding, is that if you tell the compiler what types you'll be using it can compile everything ahead of time.

  • mccoyb 18 hours ago ago

    > Julia's "secret sauce", the dynamic type system and method dispatch that endows it with its powers of composability, will never be a feature of languages such as Fortran. The tradeoff is a more complex compilation process and the necessity to have part of the Julia runtime available during execution.

    > The main limitation is the prohibition of dynamic dispatch. This is a key feature of Julia, where methods can be selected at run time based on the types of function arguments encountered. The consequence is that most public packages don't work, as they may contain at least some instances of dynamic dispatch in contexts that are not performance-critical. Some of these packages can and will be rewritten so that they can be used in standalone binaries, but, in others, the dynamic dispatch is a necessary or desirable feature, so they will never be suitable for static compilation.

    The problem (which the author didn't focus on, but which I believe to be the case) that Julia willingly hoisted on itself in the pursuit of maximum performance is _invoking the compiler at runtime_ to specialize methods when type information is finally known.

    Method dispatch can be done statically. For instance, what if I don't know what method to call via abstract interpretation? Well, use a bunch of branches. Okay, you say, but that's garbage for performance ... well, raise a compiler error or warning like JET.jl so someone knows that it is garbage for performance.

    Now, my read on this work is the noble goal of prying a different, more static version of Julia free from this compiler design decision.

    But I think at the heart of this is an infrastructural problem ... does one really need to invoke the compiler at runtime? What space of programs is that serving that cannot be served statically, or with a bit of upfront user refactoring?

    Open to be shown wrong, but I believe this is the key compiler issue.

    • DNF2 4 hours ago ago

      This is not how I understand the performance model. Allowing invokation of the compiler at runtime is definitely not something that is done for performance, but for dynamism, to allow some code to run that could not otherwise be run.

      In performant Julia code, the compiler is not invoked, because types are statically inferred. In some cases you can have dynamic dispatch, but that doesn't necessarily mean that the compiler needs to run. Instead you can get runtime lookup of previously compiled methods. Dynamic dispatch does not necessitate running the compiler.

      • mccoyb 2 hours ago ago

        I don't believe it, otherwise why not just compile a static but generic version of the method with branches based on the tags of values? ("Can't figure out the types, wait until runtime and then just branch to the specialized method instances which I do know the types for")

        Perhaps there is something about subtyping which makes this answer ... not correct -- and if someone knows the real answer, I'd love to understand it.

        I believe that this answer is because of performance -- if I can JIT at runtime, that's great -- I get dynamism and performance ... at the cost of a small blip at runtime.

        And yes, "performant Julia code" -- that's the static subset of the language that I roughly equated to be the subset which is trying to be pried free from the dynamic "invoking the compiler again" part.

  • nineteen999 17 hours ago ago

    > My experiments with a "hello world" program resulted in a 1.7MB binary and a directory of library files that occupied a further 91MB

    lol

    • pjmlp 11 hours ago ago

      If you want to LOL even more, see Rust or Go with a full static linked binary without using something like UPX.

      • nineteen999 11 hours ago ago

        I have, and what's worse, those ecosystems full on encourage static linking as a panacea, at least Rust used to.