What is the difference between procedural programming and functional programming?

Question :

What is the difference between procedural programming and functional programming?,

Answer :

I’ve read the Wikipedia articles for both and , but I’m still slightly confused. Could someone boil it down to the core?

,

A functional language (ideally) allows you to write a mathematical function, i.e. a function that takes n arguments and returns a value. If the program is executed, this function is logically evaluated as needed.1

A procedural language, on the other hand, performs a series of sequential steps. (There’s a way of transforming sequential logic into functional logic called  style.)

Read More  mod_rewrite to alias one file suffix type to another

As a consequence, a purely functional program always yields the same value for an input, and the order of evaluation is not well-defined; which means that uncertain values like user input or random values are hard to model in purely functional languages.


1 As everything else in this answer, that’s a generalisation. This property, evaluating a computation when its result is needed rather than sequentially where it’s called, is known as “lazinessâ€. Not all functional languages are actually universally lazy, nor is laziness restricted to functional programming. Rather, the description given here provides a “mental framework†to think about different programming styles that are not distinct and opposite categories but rather fluid ideas.

Read More  Memory leak detectors for C?

That’s the answer What is the difference between procedural programming and functional programming?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you