At 34786, tilly discusses an HTML::Parser-type thingy he wrote, but instead of using procedural programming, he used functional programming.

If you're like me, you probably don't know what the difference is. Here's the definitions tilly gave:

  1. Imperative programming is when you spend your time telling the computer what to do.
  2. Functional programming, build some functions, put them together into bigger ones, when you are done run your masterpiece and call it a day.
  3. Objective programming access properties of things and tell them to accomplish tasks for you without caring what happens under the hood.
  4. Logical programming starts with a series of rules and actions. When no more rules require acting on, you are done.

Now, I can definitely see what's going on here, and how the paradigms shift. Just in case you don't see it, imperative programming is what I think of when I think of ASM, for example. Brute force, "Do X, then Y, then Z", really head-achy kind of programming. We've all been forced to do some of that at some points in our lives. (Me, it was in PDP-11 on a MicroVax. *shudders*)

Then, he says that Perl is usually used for either Imperative (aka, Procedural) and Objective (aka, OO) programming. Ok. I can live with that.

Then, he gives a (very) good example of a functional module. I start reading it, expecting this completely different paradigm. But, the entire time I'm reading it, I can't help but think "dispatch table" and "functional decomposition". (I'm also thinking "Duh!", but that's beside the point.)

To me, functional programming seems to be just be well-decomposed procedural programming. Instead of putting everything in a series of statements, functional programming seems to be putting everything in a series of function calls. Abstract programming. Duh!

The only "concept" that seems to be involved here is the idea that a function-call can be a datum, hence allowing the concept of the handler and the dispatch table.

Similarly, OO programming is basically the same thing, except that you introduce the concept of the namespace and enforced scoping. You aren't adding anything really all that new to programming theory. The only new concept here is "This is mine and that is yours and ne'er the two shall meet".

It also seems to be an evolution of functional programming, in the way that functional is an evolution of imperative programming. You now have function-calls as data as well as data-hiding.

Now, I'm not going to extend this analogy into logical programming as the only experience I have with logical programming is very limited work with makefiles.

I guess my meditation is more of a question on whether or not I'm missing something. I guess I just don't get the big distinction (except with logical programming, but that's more of a lack of experience than anything else).

If you're working with a stream of events (such as events, html tags, or anything else that comes in packets), it just makes sense to write a function to handle each type of packet. Hence, functional programming.

If you're working with stuff that has to maintain state, you need data. If the data is well-formed, then you're going to have functions associated with that data. Hence, objective programming.

You don't write something to handle a stream of packets in an objective schema and you don't write something to handle well-formed data that has to maintain state in a functional schema.

Maybe, I'm being dense, but I'm just not getting the big deal.

------
We are the carpenters and bricklayers of the Information Age.

Vote paco for President!


In reply to What's the big deal? by dragonchild

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.