Note that there are some explanatory texts on larger screens.

plurals
  1. POTruly understanding the difference between procedural and functional
    text
    copied!<p>I'm really having a hard time understanding the difference between <em>procedural</em> and <em>functional</em> programming paradigms.</p> <p>Here are the first two paragraphs from the Wikipedia entry on <em>functional programming</em>:</p> <blockquote> <p>In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in lambda calculus, a formal system developed in the 1930s to investigate function definition, function application, and recursion. Many functional programming languages can be viewed as elaborations on the lambda calculus.</p> <p>In practice, the difference between a mathematical function and the notion of a "function" used in imperative programming is that imperative functions can have side effects, changing the value of program state. Because of this they lack referential transparency, i.e. the same language expression can result in different values at different times depending on the state of the executing program. Conversely, in functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function <code>f</code> twice with the same value for an argument <code>x</code> will produce the same result <code>f(x)</code> both times. Eliminating side effects can make it much easier to understand and predict the behavior of a program, which is one of the key motivations for the development of functional programming.</p> </blockquote> <p>In paragraph 2 where it says</p> <blockquote> <p>Conversely, in functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function <code>f</code> twice with the same value for an argument <code>x</code> will produce the same result <code>f(x)</code> both times.</p> </blockquote> <p>Isn't that the same exact case for procedural programming?</p> <p>What should one look for in procedural vs functional that stand out?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload