3 ms·
There is so much performance left on the table by strongly typed functional languages when it comes to optimization. Unfortunately, it seems most functional la
by darksaints 6y ago
There is so much performance left on the table by strongly typed functional languages when it comes to optimization.
Unfortunately, it seems most functional languages are built on infrastructure that was intended for procedural languages (Rust->llvm, F#->.Net, Scala->JVM, etc.) . This means that by the time that infrastructure starts working on the code, it has already been stripped of its most valuable inferential assets: the resolved types, the statically determined immutability, etc..
Rust is the first language I've seen that is trying to do something about it. I think the idea is that MIR is an intermediate language that still retains type information, after lifetimes have been resolved. Using this, they can implement better analysis and preoptimize code before it hits LLVMs optimizers.
- azhenley 6y ago> Unfortunately, it seems most functional languages are built on infrastructure that was intended for procedural languages But what about Haskell and Scheme? They’re the first two languages that come to mind when I think functional. I think all those other languages are built on existing infrastructures like .Net or JVM because infrastructure is one of the biggest barriers for any language. I’d love to see a general purpose platform designed for functional languages, but I don’t even know what that would look like.
- dsstuifg 6y agoWell, haskell has the problem of lazyness being the default execution model, which doesn't really help.
- shpongled 6y ago> Rust is the first language I've seen that is trying to do something about it. I think the idea is that MIR is an intermediate language that still retains type information, after lifetimes have been resolved. Using this, they can implement better analysis and preoptimize code before it hits LLVMs optimizers. MLton also keeps type information around basically until machine code generation (as far as I understand, at least). There have also been several interesting papers/projects about typed assembly languages.
- steveklabnik 6y agoThe borrow checker nowadays operates on MIR, it is not done before MIR.
- darksaints 6y agoWas that how you got non-lexical lifetimes? Is it using data flow analysis during that?
- steveklabnik 6y agoYep! MIR is CFG based rather than AST based.
- jkachmar 6y agoIf you’re not already familiar with it, you may find the GRIN (Graph Reduction Intermediate Notation) compiler project interesting: https://github.com/grin-compiler/grin https://github.com/grin-compiler/grin