From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA14115 for caml-red; Sat, 4 Nov 2000 15:44:23 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA06769 for ; Fri, 3 Nov 2000 23:53:14 +0100 (MET) Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net [206.13.28.240]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id eA3MrDT15464 for ; Fri, 3 Nov 2000 23:53:13 +0100 (MET) Received: from checkerlap.d6.com ([64.160.52.206]) by mta6.snfc21.pbi.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with ESMTP id <0G3H0053J0UAQY@mta6.snfc21.pbi.net> for caml-list@inria.fr; Fri, 3 Nov 2000 14:51:46 -0800 (PST) Date: Fri, 03 Nov 2000 14:44:41 -0800 From: Chris Hecker Subject: practical functional programming X-Sender: def6@shell16.ba.best.com To: caml-list@inria.fr Message-id: <4.3.2.7.2.20001103055229.00ab6880@shell16.ba.best.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Content-type: text/plain; charset="us-ascii" Sender: weis@pauillac.inria.fr 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