From: Robert Klemme Date: 2005-10-03T23:21:46+09:00 Subject: Re: Functional Programming? (was Re: Lazy evaluaton) Edward Faulkner wrote: > On Sun, Oct 02, 2005 at 05:16:45AM +0900, Jay Levitt wrote: > > From reading this thread, I would have assumed that FP is another > > word for "procedural" but clearly it's much, much more. > > Indeed, functional programming is almost the *opposite* of procedural. > In a procedural program, most lines are executed for their side > effects. In a functional program, most lines are executed for their > value. > > The key idea in functional programming is that the functions you > define are functions in the mathematical sense. If you call one twice > with the same arguments, you'll always get the same answer each time. > They have no internal state and no side effects. I was going to write something similar. Thanks for confirming that my rusty CS knowledge on functional programming was not completely outdated! > In practice most programs need non-functional parts too, but you can > keep those isolated. .... and all functional languages with some significance have non functional extensions (like side effects, variables etc.). > By keeping your code functional, you make it easier to test and debug. > It's inherently thread safe, and optimizations like lazy evaluation > and memoization can be introduced transparently by the > compiler/interpreter. IIRC another property of (pure) functional programs is that they are easier to reason about mathematically and thus to verify (probably because functions resemble very much mathematical functions). Kind regards robert