HN comment on Julia vs Swift type checking and auto diff

I was going to comment with something like this. I’d only add that since the debugger tools have hit the scene this is a thousand times easier.

3 Likes

Thanks for all the insights everyone, and good to hear from the core team.

There are two issues here, static checking for behavior verification and static checking for performance. These sound decoupled to an extent.

I have some follow up questions, if anyone would like to field them:

-For the latter, I’m excited about allocation reduction. @StefanKarpinski I assume this is what is implied in static subset for TPU etc? Will the same sort of thing be helpful for running Julia on embedded devices, deploying small Julia runtime free WASM binaries etc?

-Is compile time behavior verification (like array shape mismatches etc) also an intended goal?

-Will the logic of static typing restricting compiler development not apply to this static subset as well?

Edit: Maybe behavior isn’t the right word. Is a method error “behavior”? Would semantic be better?

So I am curious about static check for behavior verification. Does that apply to a dynamic language? What for instance happens in the Python world, where there are never static types to verify in the first place? So is the real question, how do you verify the type inference system applies the correct method, regardless of whether it was inferred or dynamic?

The reason why Python cannot get complete inference support is, you cannot forever make sure what you’ll get from a import statement as the existence of dynamic import mechanism(There’re bunch of PEPs about import iterations, which makes Python import powerful but undecidable as well). Julia seems to have better properties in this aspect, thus we can allow enabling a more reasonable static type checking.

how do you verify the type inference system applies the correct method, regardless of whether it was inferred or dynamic?

There’s already something called Gradual Typing which provides the capability of supporting static typing and dynamic typing in solely one language. AFAICT, the necessary insertions would be inserted into the occurrences that dynamic types coerced to a static world, not sure whether it works the best way for Julia but I think there must be a few workarounds.

1 Like

I feel like you could make the case that via @nospecialize
julia has Gradual UnTyping.
Or UnType annotations.

1 Like