back

by bikeshaving·5y ago·view on hn ↗
If you’re interested in a language which does claim to optimize pure functions, take a look at Koka (https://koka-lang.github.io/koka/doc/index.html), a research language from Microsoft. It doesn’t implement any control flow besides conditionals and pattern matching; everything else is implemented with higher-order functions, and a cool syntax which allows trailing callback parameters to look like a block of code makes it look almost imperative. Additionally, they have a complex effect tracking system which tracks not only if a function is pure, but also things like if it might be non-terminating or throw errors. Somehow this is used to transform functional code into code which is about as fast as the imperative equivalent.

Ultimately, I think reasoning about function effects in such a fine-grained way probably won’t catch on, but it’s a great example of what you can do when you design compiler up. However, the original article, and most in production functional systems, are about attempting to carve out a functional system from imperative parts. The result is like you said, we’re executing unoptimized code.