Re:Reducing Rust Incremental Compilation Times on macOS
by gpderetta on Sunday April 18, 2021 @01:46PM
(#26854651)
That's not an answer though. I believe (but I know little of both Haskell and Rust) that Haskell polymorphism is at least as powerful as rust static polymorphism but it is normally implemented via type erasure.
I think the real reason is that rust gives additional guarantees about lack of allocation and object layout that are hard to implement with dictionary passing (BitC tried and failed).
Re:Reducing Rust Incremental Compilation Times on macOS
by Tyr42 on Sunday April 18, 2021 @03:30PM
(#26855540)
I agree somewhat, in Haskell you can write generic functions without traits, and I think they are not monomorphized. (map for example.)
However, I think these all operate on boxed objects, which is a little bit easier to do than for Rust, where only some objects are boxed.
In short, I agree.
Static dispatch:
is (handwaves) first translated to a version with no generics You can probably see how the more permutations of functions you need to generate the slower it gets.Dynamic dispatch:
This translates to (handwaves): This is simple to compile, but you need to do some extra work at runtime.