Thursday, December 21, 2006

Grr!!

Bruce Tate is no dummy. Far from it. But his otherwise very interesting introduction to Haskell says that Haskell's "style of lazy processing makes functional languages much more efficient than you'd otherwise expect and allows a powerful abstraction called infinite streams that's not available to other programming languages."

Not available in other programming languages?

You can do this in Perl! It's easy!



OK, maybe easy isn't the word. But it's easier than you'd think. There's a lot about infinite streams in Perl in this book, and it's a pretty good book, btw. Not only that, if you read Hal Fulton's The Ruby Way, there's a section of that where code by Jim Weirich uses continuations to create infinite streams as well. (They call them generators in that book, but they're effectively infinite streams.)

Anyway, I don't think most people would describe either Perl or Ruby as "functional languages," but infinite streams are easy to produce in either one.

(Other than that, though, the Haskell article is pretty good.)

2 comments:

  1. Okay, Clean and Haskell uses graph reduction techniques to implement lazy evaluation.

    Graph reduction allows for cheap memoisation, so, for example, when you multiply two infinite streams of power series coefficients you do not need to recalculate one of them on constant basis.

    Try to implement multiplication from this paper: http://citeseer.ist.psu.edu/karczmarczuk97generating.html

    If you succeed too early, try to implement square root. ;)

    ReplyDelete
  2. I had a similar thought when reading a Haskell-evangelizing blog post that talked about infinite data structures. In my case I thought "Hey, you can do that in Python", and wrote some code to prove it to myself (http://dpaste.com/hold/4485/). Haskell is really nifty, though; it's my "try to learn it" language for 2007.

    ReplyDelete

Note: Only a member of this blog may post a comment.