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:

    In everyone’s youthful dreams, philosophy is still vaguely but inseparably, and with singular truth, associated with the East, nor do after years discover its local habitation in the Western world. In comparison with the philosophers of the East, we may say that modern Europe has yet given birth to none.
    Henry David Thoreau (1817–1862)

    Because humans are not alone in exhibiting such behavior—bees stockpile royal jelly, birds feather their nests, mice shred paper—it’s possible that a pregnant woman who scrubs her house from floor to ceiling [just before her baby is born] is responding to a biological imperative . . . . Of course there are those who believe that . . . the burst of energy that propels a pregnant woman to clean her house is a perfectly natural response to their mother’s impending visit.
    Mary Arrigo (20th century)

    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)