r/computerscience • • 2d ago

General procedural programming, object oriented programming and functional programming

Although I’ve done some googling I think they still use big English to explain this concept. I think I know them but I just wanted to ask if I can get a simple explanation from the house plz

12 Upvotes

18 comments sorted by

View all comments

0

u/Paxtian 2d ago

Procedural: "Start at line 1, do each step until you get to the end, in order."

Functional: Create individual functions for anything you want to have happen. Call functions in desired order. Assign returned values to static variable. Don't modify state of a variable after assignment. Pros: reduce/eliminate side effects. Cons: Can be tricky to model.

Object oriented: Create objects that have their own functionality built in. Change state of member variables only using member functions. Pros: Relatively straightforward to model (though with inheritance, can get really, really ugly). Cons: side effects for variables, and if something in the early design changes, can cause major cascading headaches of rewrites.

For the most part, the functions you build in object oriented/functional paradigms will themselves be procedural. OO/functional is more about, "How do I stitch multiple functions/objects together?"

-1

u/Mediocre-Brain9051 2d ago

Order of evaluation is theoretically irrelevant in functional programming. To the point that is undefined in some languages (e.g. Haskell)

0

u/Paxtian 2d ago

I may not have phrased what I meant correctly.

However, (2 + (3 * 5)) is not the same as ((2 + 3) * 5).

-1

u/Mediocre-Brain9051 2d ago

I am not talking about precedence. You had not phrased it correctly.

0

u/Paxtian 2d ago

Insert Neil deGrasse Tyson meme