Re:The Swift compiler is slow due to how types are inferred
by pcwalton on Wednesday June 12, 2024 @04:27PM
(#40662710)
Yeah, I agree. Regular H-M typechecking if you don't have subtyping is actually really fast. The problem is that subtyping makes it really complicated--in fact, IIRC, formally undecidable.
[ Parent
| on HN ]
Re:The Swift compiler is slow due to how types are inferred
by mmoskal on Wednesday June 12, 2024 @09:55PM
(#40665172)
It's funny because it's doubly exponential WRT code size. However it's also almost linear (n log*(n) due to union-find) WRT the size of the type and sane humans don't write programs with huge types.
Re:The Swift compiler is slow due to how types are inferred
by nextaccountic on Friday June 14, 2024 @05:20AM
(#40679088)
I don't know about Swift, but in Rust there are libraries like Diesel that essentially builds a new type out of the operations you run (in Diesel's case, it's used to type a SQL query), which may lead to huge types in ordinary code.
Programmers don't manually write those types however.
Re:The Swift compiler is slow due to how types are inferred
by Weebs on Thursday June 13, 2024 @11:04AM
(#40670601)
Afaik that is true of traditional HM, but fortunately there was a big advancement in inferring subtypes w/ Dolan's Algebraic Subtyping a few years ago! It's not nearly as fast as HM (O(n^3) worst case) but generally fast enough in real code