Version française
Home     About     Download     Resources     Contact us    
Browse thread
practical functional programming
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: practical functional programming

So, I've been reading some papers by Okasaki on functional data structures, and I've ordered his book.  I have some questions, and I don't mean these to be flame bait; they're honest questions from an imperative programmer trying to grok this functional thing.

First, let me say that I love the idea of higher order functions, currying, closures, variant types, pattern matching, gc, and the like.  I think I understand some of the power that comes with those techniques, and I'm eager to try them in a real sized project.

However, after reading Okasaki's papers about functional datastructures, I'm not sure I get why someone would go to all that trouble.  In other words, I can trivially write an O(1) queue using imperative languages (or imperative features of a funcional lanugage, like caml's queue.ml).  Okasaki goes to a _lot_ of trouble to implement an O(1) queue in a pure functional way, using all sorts of lazy optimizations and scheduling and whatnot.  He acheives O(1), but the constant is going to be rather large compared to shuffling a pointer/ref around in C/caml.

So, what does all this trouble buy you?  I vaguely understand how a purely functional language like Haskell might be more amenable to analysis and proof than C, but people jump through hoops to get that (read: IO monads in Haskell, Okasaki's datastructures).  Is it worth it?  Clearly the caml folks didn't think so because the standard library datastructures are destructively modifying.

I'm open minded, so I'm genuinely interested to know if the work of making something like a simple datastructure purely functional is more than an academic exercise, or if it pays back in real-sized production software.

Chris