News for hackers. Stuff that matters.
Re:Type Stability in Julia: Avoiding Performance Pathologies... by xiphias2 on Wednesday December 08, 2021 @10:50PM (#29493619)
When I was working with Julia I wanted it to just throw an error whenever a top level program was compiled to unstable types. I didn’t find a way to do it though :(
Re:Type Stability in Julia: Avoiding Performance Pathologies... by fault1 on Wednesday December 08, 2021 @11:56PM (#29493977)
One problem is Julia is just ahead of time compiled, so you need something like JET to iteratively run stability analysis via abstract interpretation if you intend to run it for a top level program: https://aviatesk.github.io/JET.jl/dev/optanalysis/

It recently got support on vscode.

What was available in Julia before (things like @code_typed) are only applicable locally, so there is only limited benefit. Because linters have dramatically improved in recent years, it feels like Julia was lagging behind until recently.

Actually thinking about it, Julia could use something like refinement types ala Liquidhaskell: http://ucsd-progsys.github.io/liquidhaskell-tutorial/Tutoria...

Re:Type Stability in Julia: Avoiding Performance Pathologies... by adgjlsfhk1 on Wednesday December 08, 2021 @11:39PM (#29493883)
Julia has the `@infered` macro in `Test` that throws an error if your code isn't type stable.
Re:Type Stability in Julia: Avoiding Performance Pathologies... by ulysses4ever on Thursday December 09, 2021 @11:20PM (#29506348)
I absolutely agree that providing a tool to _assert_ stability (just like usual @assert) would be great. We thought about it when writing the paper but never got to device anything like that. For smooth integration, that would probably require hacking on Julia itself.
Re:Type Stability in Julia: Avoiding Performance Pathologies... by leephillips on Wednesday December 08, 2021 @11:10PM (#29493729)
Do you know about the code_warntype macro and function?
Re:Type Stability in Julia: Avoiding Performance Pathologies... by kwertzzz on Thursday December 09, 2021 @04:08AM (#29495316)
The code_warntype macro is helpful, but to prevent a future inadvertently introduced type stability, a failing test would be much better.

Test.@inferred is not quite what is needed:

    function foo(x)
      s = 0 
      # better use a zero of the same type than x
      # s = zero(x)
      for y in x
        s += y
      end
      return s
    end

    Test.@inferred Float64 foo(12.1) 
This test succeeds even if code is type-unstable