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.

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.