in reply to Re: If not 'Functional Programming', then what?
in thread If not 'Functional Programming', then what?
I was writing about Perl programming techniques that I learned from a Lisp programmer. Since they were techniques that used anonymous functions a lot, I thought that "functional programming" was a good description.
At the time I lacked the programming background to know that "functional programming" was already used to refer to a specific style of side-effect free programming. People who use that style also use a lot of the same techniques that I was using. But they consider those techniques to be basic building blocks, and not at all the point of what they are trying to do.
Really? I thought it was the other way around: side-effect-free programming makes it possible program in a fully functional way, because side-effect-free functions live "outside of time" just like numbers. So it seems to me that what you call "functional techniques" is very much the point of Haskell.
I'm just learning about Haskell, but it is already clear to me that Haskell invests a lot of effort on making functions really first class: it lets you not only pass them to and from other functions (just like Perl does), but also provides built-in operators and other syntactic constructs for easily creating new functions and operators from existing ones.
Here are some examples of what I mean. The dot is the composition operator: f . g is the function that when applied to its arguments, say x, y, z, returns the result of applying f to g x y z.
Or curried functions: if f is a functions of two arguments, f x is the function of one argument that when applied to y returns f x y.
Or sections: if op is a binary infix operator, then (x op) is the function of one argument that when applied to, say, y returns x op y.
One can treat f.g, (f x), and (x op) just like any other function, including passing them to other functions and operators as arguments, etc.
Most of these operations on functions can be mimicked in Perl, but my point is that with Haskell one gets the message that these function-oriented facilities are really central to the goals of the language.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: If not 'Functional Programming', then what?
by tilly (Archbishop) on Apr 25, 2005 at 05:10 UTC |