Functional Programming - Comparison To Imperative Programming

Comparison To Imperative Programming

Functional programming is very different from imperative programming. The most significant differences stem from the fact that functional programming avoids side effects, which are used in imperative programming to implement state and I/O. Pure functional programming disallows side effects completely and so provides referential transparency, which makes it easier to verify, optimize, and parallelize programs, and easier to write automated tools to perform those tasks.

Higher-order functions are rarely used in older imperative programming. Where a traditional imperative program might use a loop to traverse a list, a functional program would use a different technique. It would use a higher-order function that takes as arguments a function and a list. The higher-order function would then apply the given function to each element of the given list and then return a new list with the results.

Read more about this topic:  Functional Programming

Famous quotes containing the words comparison, imperative and/or programming:

    I have travelled a good deal in Concord; and everywhere, in shops, and offices, and fields, the inhabitants have appeared to me to be doing penance in a thousand remarkable ways.... The twelve labors of Hercules were trifling in comparison with those which my neighbors have undertaken; for they were only twelve, and had an end; but I could never see that these men slew or captured any monster or finished any labor.
    Henry David Thoreau (1817–1862)

    If the Revolution has the right to destroy bridges and art monuments whenever necessary, it will stop still less from laying its hand on any tendency in art which, no matter how great its achievement in form, threatens to disintegrate the revolutionary environment or to arouse the internal forces of the Revolution, that is, the proletariat, the peasantry and the intelligentsia, to a hostile opposition to one another. Our standard is, clearly, political, imperative and intolerant.
    Leon Trotsky (1879–1940)

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)