• GetOffMyLan
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    2 months ago

    Actually jit languages can outperform compiled languages by using runtime analysis to perform tiered compilation and profile guided optimisations.

    C# has made some great strides in this regard.

    All the normal optimisations are applied when it is compiled to byte code. Like loop unrolling etc.

    Then once it detects the hot paths during execution it can apply even more based on how it is called. It can also do optimisations that aren’t possible at initial compile time.

    Dynamic PGO it’s called. It’s a really interesting topic.

    • nous
      link
      fedilink
      English
      arrow-up
      5
      ·
      2 months ago

      Can when the specific situations are reached in very micro benchmark situations. But overall on aggregate you find even JIT languages don’t strictly outperform pre compiled languages for general workflows when looking at languages of a similar class. When you compare them to compiled languages like C/C++/rust/zip (aka ones without a GC or much of a runtime at all) then JIT languages fall behind like all other GCed languages.

      • GetOffMyLan
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Most of the time yeah. But it depends as you can write c# with very little GC use if you avoid allocations.

        Ahead of time compiling also gets things much closer. But then you lose runtime optimization.

    • Feyd
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      2 months ago

      You can do PGO with GCC, though it takes extra steps of course

      • UFO
        link
        fedilink
        arrow-up
        4
        ·
        2 months ago

        That does constrain the optimizations to a profile determined prior to the end user. Which is hopefully the same but might not be. Shared code between applications also is a challenge.