4 ms·
> F# proves otherwise Not really...F# has a "slow" compiler too. Any advanced type system, whether F#, C++, Haskell, Scala, Rust, TypeScript...is inevitably g
by paulddraper 7y ago
> F# proves otherwise
Not really...F# has a "slow" compiler too.
Any advanced type system, whether F#, C++, Haskell, Scala, Rust, TypeScript...is inevitably going to have a significantly slower compiler than a more basic system (Go, Java, C).
That's just part of the tradeoff; though obviously you can optimize within those bounds.
It's about as universal as the runtime "rule": compiled perf > interpreted perf. Not technically inviolable, but practically so.
---
P.S. And while the F# compiler is indeed faster than rustc, it's not apples-to-apples. F# compiles to CLR; Rust compiles through LLVM all the way to native. If Rust deferred work to runtime with an LLVM interpreter (http://llvm.org/docs/CommandGuide/lli.html http://llvm.org/docs/CommandGuide/lli.html ?), it would improve compile-time performance, at the cost of runtime overhead.
- throwaway894345 7y agoI don't think this is true. C compilers often have a whole bunch of optimizations built in, which could easily make them quite a lot slower than a less-optimized compiler for a language with a more advanced/complex type system. There are other factors as well, such as the efficiency of the compiler--the same C compiler implemented in C and compiled with an advanced C compiler will handily beat a C compiler written in Python and executed on CPython. But to your point, all-else-equal, a program in a language with an advanced type system takes longer to compile than a simpler type system.
- paulddraper 7y agoI mention this at the end of my comment, but yes the second very significant factor is the nature of transformation. A SASS (CSS preprocessor language) compiler can be very fast because it does very little. Native compilers must do significantly more transformation than other compilers, e.g. F# CLR compiler. This is doubly so if you request optimized output (but that's probably not the case in this discussion).
- pjmlp 7y agoF# compiles to native code via Mono AOT, NGEN (available since .NET 1.0 which many seem to forget), .NET Native (does require a hack and some care due to missing support for some MSIL opcodes), Unity's IL2CPP. Naturally Rust could offer an interpreter of some sort, however it still isn't there today, so we got to use what is available.
- sitkack 7y agoA similar path might be MIR to Wasm, w/o hitting LLVM at all. Or just interpret MIR directly.
- whb07 7y agoShould checkout the Ocaml compiler. It is wicked fast.