Functional Programmers: Why we call them first-class citizens?
In programming language design, a first-class citizen (also type, object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, and assigned to a variable. In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens.
Functional languages — languages where functions are the primary means of building programs — all have first class functions.
When you say that a language has first-class functions, it means that the language treats functions as values – that you can assign a function into a variable, pass it around etc. Higher-order functions are functions that work on other functions, meaning that they take one or more functions as an argument and can also return a function.
The “higher-order” concept can be applied to functions in general, like functions in the mathematical sense. The “first-class” concept only has to do with functions in programming languages. It’s seldom used when referring to a function, such as “a first-class function”. It’s much more common to say that “a language has/hasn’t first-class function support”.
First-class value can be
- passed as an argument
- returned from a subroutine
- assigned into a variable
Second-class value just can be passed as an argument.
Third-class value even can’t be passed as an argument.
When it comes to functional programming, Python is classified as a “hybrid” language. It supports the functional programming paradigm, but equally supports imperative paradigms (both procedural and object-oriented). Other languages with built-in support for programming in a functional paradigm as well as other paradigms are: F#, C#, Scala, Java 8.
Take Away
Functional programming proved to be booster to success of big data revolution. The main reason is that functional programming facilitates distributed programming.
Does the above interest you? Explore what it takes to use functional programming for Big Data Analytics at Busigence. Apply at http://goo.gl/DMpmN4