6

Silly question: what is the main difference between a procedural programming paradigm and a functional paradigm?

Comments
  • 7
    in a 🥜🐚

    Prodecural: do one thing or flow of actions with fixed start and end point

    Funxtional: perform granularized bits of code in no concrete order or amount

    this is a loose formulation for understanding purposes.
  • 2
    @beggarboy ++ for the nut and the shell
  • 5
    @beggarboy . I think your concise explanation was a bit too concise. Procedural and functional are not mutually exclusive. Indeed, at the end of the day, all applications are procedural to some degree. Some more so than others with Skyrim and the Google maps API as examples of things near opposite ends of the spectrum. The question itself is a little odd in that it's more appropriate to compare functional vs. OOP and procedural vs. event driven.
  • 0
    @norman70688 that's declarative vs whatever the opposite is. Functional languages just happen to be declarative.
  • 2
    In procedural code you organise things as a bunch of procedures or lists of "do this, do that" steps. You generally end up specifying everything and it generally has a lower level feel.

    Functional programming's distinctive feature is that functions are everyday values and they can be passed to functions and returned from functions just like other values. Eg. a standard "map" function takes a collection to work over, like a list, and a function to apply to every element in that list. That's classic functional programming. Other features generally associated with FP are purity (functions tend to avoid side effects), organising code around function composition, and laziness (code does minimum required), though none of these are actually necessary for FP.

    They're not really mutually exclusive. Heck you can mix them as you want. You can do OOP style dynamic dispatch in Haskell (existential types), FP in C, and procedural in Java, they're just not based around it.
  • 0
    Let's say: a function is a litle procedural program.
    U can build up ur understanding starting from here
    :)
  • 0
    @monkeyboy I don't disagree, hence why I declared that it should be taken with a pinch of salt.
Add Comment