Functional Programming: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


The ability to pass functions as arguments and no shared mutable data are the cornerstones of functional programming. Functional programming is essentially different than ''imperative programming'', where a program is described in terms of a sequence of statements that mutate state.
The ability to pass functions as arguments and no shared mutable data are the cornerstones of functional programming. Functional programming is essentially different than ''imperative programming'', where a program is described in terms of a sequence of statements that mutate state.
[[Java#Java_8|Java 8]] introduced [[Java 8 Lambda Expressions#Overview|lambda expressions]], which allow [[#Behavior_Parameterization|behavior parameterization]] and functional programming.


Closures and recursion are at the base of the ''functional programming'' paradigm.
Closures and recursion are at the base of the ''functional programming'' paradigm.
[[Java#Java_8|Java 8]] introduced [[Java 8 Lambda Expressions#Overview|lambda expressions]], which allow [[#Behavior_Parameterization|behavior parameterization]] and functional programming.


=Behavior Parameterization=
=Behavior Parameterization=

Revision as of 18:57, 22 March 2018

Internal

Overview

The ability to pass functions as arguments and no shared mutable data are the cornerstones of functional programming. Functional programming is essentially different than imperative programming, where a program is described in terms of a sequence of statements that mutate state.

Java 8 introduced lambda expressions, which allow behavior parameterization and functional programming.

Closures and recursion are at the base of the functional programming paradigm.

Behavior Parameterization

Prior to Java 8, behavior parameterization was possible with anonymous classes. In Java 8, functions can be explicitly passed to the API, as parameters, and returned as results.

Function

Pure Function

A piece of behavior that is perfectly descried solely by the way it transform arguments to results, behaving as a mathematical function and having no side effects. Also known as side-effect-free function or stateless function.

Also see Parallelism.

Closures

Closures