Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re^2: If not 'Functional Programming', then what? by tlm
in thread If not 'Functional Programming', then what? by t'mo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found