Slashdot Mirror


Why Lazy Functional Programming Languages Rule

Da Massive writes "Techworld has an in-depth chat with Simon Peyton-Jones about the development of Haskell and his philosophy of do one thing, and do it well. Peyton-Jones describes his interest in lazy functional programming languages, and chats about their increasing relevance in a world with rapidly increasing multi-core CPUs and clusters. 'I think Haskell is increasingly well placed for this multi-core stuff, as I think people are increasingly going to look to languages like Haskell and say 'oh, that's where we can get some good ideas at least', whether or not it's the actual language or concrete syntax that they adopt.'"

4 of 439 comments (clear)

  1. Re:Mmmm, Kay. by david.given · · Score: 0, Troll

    If you have an explanation, why not give it?

    Why should I? I spent time and effort composing a response to Dragonslicer's original query. Dragonslicer then responded by being an ass. Why should I waste any further time? I've got better things to do.

  2. Re:Mmmm, Kay. by Dragonslicer · · Score: 0, Troll

    I'm well aware (as well as I can be, at least, having been out of school for a few years now) of the benefits of all of the theoretical work with concepts like Turing machines. I'm certainly not saying that such concepts are useless or unimportant. Here on the outside of academia, though, we don't usually have wires with infinite bandwidth, disks capable of storing infinite frames of video, or users that can press infinite keys.

    As for being an ass, I have to say that it's a bit deserved. Participating in a discussion that's arguably about computer science theory and grossly misusing the word "infinite" doesn't make you very credible.

  3. Re:Mmmm, Kay. by Grishnakh · · Score: 0, Troll

    If you don't believe me, look at the human race. Do you think that high intelligence or great beauty are driving evolution forward? Or is it "good enough" people who reproduce a lot?

    I'd say it's the opposite: highly intelligent people usually don't reproduce much, if at all, whereas utterly stupid people reproduce at an astonishing rate. The solution? I have no idea. The obvious solutions (which usually have something to do with eugenics, forced sterilization, etc.) aren't really palatable, and since average people are in the majority anyway, they're not going to accept them in a democratic society. Of course, we could abandon democracy, but the alternatives are usually worse. When they do work, they usually only do so for a while (while the good leaders are still around), but eventually become corrupted and end up much worse than the democratic alternative.

    Besides, it's been shown that a lot of a person's intelligence is based on nurture, not nature; raising kids in a good environment probably helps them a lot more than simply having good genes. Intelligent people, knowing their time is valuable and limited, don't usually have many children because they know there's not enough time for them to accomplish much and also raise 13 kids, whereas stupid people happily have 13 kids because they know the government will give them a big welfare check for it, and time isn't a problem since they can just ignore the kids and go drinking instead of putting any effort into raising them.

  4. Re:Mmmm, Kay. by david.given · · Score: 0, Troll

    As for being an ass, I have to say that it's a bit deserved. Participating in a discussion that's arguably about computer science theory and grossly misusing the word "infinite" doesn't make you very credible.

    And yet, a number of people, not just me, were using the term as if it meant something... which should have been your clue that your understanding was flawed.

    Here's the clue: Haskell is a *lazy* language. This means it only evaluates things as it needs to. This allows it to operate on representations of infinite amounts of data, by only actually needing to do the operations on the data required right now. So, you can construct a list that contains all the members of the fibonacci sequence, and while summing all the members will take an infinite amount of time, summing a finite subset of the members will take a finite amount of time.

    This applies to I/O: your program is a function which takes, as a parameter, a infinite list of keyboard events. It returns a list of characters (which may be infinite if your program never halts). Your entire program logic then becomes a mapping between input events and output events. Something like:

    main i = map i (1 +)

    (very dodgy syntax, this was all years ago) returns an infinite list which is a copy of the input infinite list with all the elements incremented by one. Press an A, and it'll print a B. Of course, you're probably going to ^C it before very long, but it doesn't escape the fact that the program is quite happily operating on lists that it considers to be infinitely long --- one element at a time.

    (In fact, that's a huge simplification; the real thing is significantly more complex and uses things call monads for dealing with all this that are infamously nasty. I don't pretend to understand them.)