Welcome to the Monastery | |
PerlMonks |
What's the big deal?by dragonchild (Archbishop) |
on Sep 01, 2001 at 01:29 UTC ( [id://109560]=perlmeditation: print w/replies, xml ) | Need Help?? |
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:
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. ------ Vote paco for President!
Back to
Meditations
|
|