3 ms·
Lazy evaluation lists is nice. Strongly typed and purely functional are very appealing, but lazy evaluation is what really differentiates Haskell in my opinion
by rudolph9 6y ago
Lazy evaluation lists is nice.
Strongly typed and purely functional are very appealing, but lazy evaluation is what really differentiates Haskell in my opinion. `take 5 (repeat 0) —- [0,0,0,0,0]` and equivalent in hask `take(5, L[0, 0, ...])`
I wonder how ubiquitous lazy evaluation is?
- scns 6y agoSimon Peyton Jones said that lazy evaluation was a mistake.
- MycroftJones 6y agoGlad to hear he said that. He is right.
- rudolph9 6y agoCan you elaborate on your thoughts?
- rudolph9 6y agoWhen did he say that? From what I have read he has stated that it forced purity and I’d be interested to see the context where he calls it a “mistake”.
- rudolph9 6y ago> Host: How did laziness and purity come together? Simon Peyton Jones: So, Haskell’s initial defining characteristic was that it was a lazy language. That’s what brought that particular group of people together, what we thought was exciting and cool. But in retrospect, I now think what was much more important was that laziness forced Haskell to be a pure language. By which I mean, in a call-by value functional language like ML or Lisp, if you wanted to print something it was too tempting to have a function, in quotes, which, when you call it, would print something as a side effect. That is, it wouldn’t just return well what would print return? Unit or 3 or something. But it would print something on the side. So, we couldn’t do that in a lazy language because we couldn’t predict the evaluation order well enough. So, laziness kept us pure. And purity was embarrassing for a long time, because you couldn’t really do much by way of input/output. You couldn’t print things or open files or launch missiles or sail the boat. So that forced us to invent what came to be called monadic input/output. And there was another classic example which Phil Wadler, my colleague at Glasgow, took ideas from the logic world. The theory of monads developed by various people. But he was particularly drawn on the work of Eugenio Moggi, who was very much a theorist. Phil Wadler wrote this wonderful paper comprehending monads in which he described monads as a programming idiom. And then he and I subsequently wrote a paper called ‘Imperative Functional Programming’ which showed how you can apply monadic programming to do input/output to affect the world. And that idea has been wildly infectious. That’s spread to all sorts of places. So, people now use the monadic thought pattern as a design idea for designing their programming languages or ways to… you could see it all over the place now. But it only happened because we were stuck with purity because we had laziness. It was another place where the sort of theory both helped the practice and also almost forced the practice, because we would have had to break with our principles too much to just have side effects. So, we were stuck with no side effects and were forced to invent this alternative way of going about things. https://www.microsoft.com/en-us/research/podcast/functional-programming-languages-pursuit-laziness-dr-simon-peyton-jones/ https://www.microsoft.com/en-us/research/podcast/functional-...