Re:Interview with Simon Peyton-Jones
by Kootle on Thursday April 19, 2018 @04:28PM
(#16879823)
Haskell's type system works because of purity, and purity doesn't generally mesh well with performance-oriented applications like game engines. There are some type-driven approaches to gamedev, like https://github.com/jonascarpay/apecs, but it's fairly experimental. There has been some talk about linear types, which would allow Haskell to have controlled impurity similar to Rust, but they're still a ways off.
[ Parent
| on HN ]
Linear types support is coming along nicely, there is a fork of GHC with a prototype implementation.
https://github.com/tweag/ghc/tree/linear-types
However, to allow the compiler to optimise pure operations to impure ones, I don't think linear types are sufficient. You need something like uniqueness types.
Re:Interview with Simon Peyton-Jones
by btcindivist on Thursday April 19, 2018 @04:41PM
(#16879955)
I think C++ compiles down to a pure functional language that is then optimized into an efficient beast. So I'm not sure that pure code is hard to optimize.
Re:Interview with Simon Peyton-Jones
by seanmcdirmid on Thursday April 19, 2018 @04:45PM
(#16879994)
SSA is quite different from a pure FP; for example it doesn’t do anything about effects, it only gets rid of local imperative assignments that don’t really interfere with purity anyways.
Re:Interview with Simon Peyton-Jones
by tathougies on Thursday April 19, 2018 @09:39PM
(#16881544)
Most imperative languages have an intermediate language in which local variables are immutable. However, purity is about more than immutability. For example, in C++
x = doSomething(x) + 1
Can be written to not overwrite x int x2 = doSomething(x) + 1
This is equivalent in some ways to Haskell let x' = doSomething x + 1
However, I know that in Haskell, evaluating 'doSomething x' will not turn off the computer, display anything to the user, or launch missiles. I have no idea what evaluating 'doSomething(x)' does in C++. It may add things to caches, exit the program, etc.