Are there any disadvantages to having first class functions in a language?
Joel in this entry says
Object-oriented programming languages aren't completely convinced that you should be allowed to do anything with functions.
I might be naïve here, but why don’t all languages support first class functions if there aren’t much issues
First-Class Function: A programming language is said to have First-class functions if functions in that language are treated like other variables. So the functions can be assigned to any other variable or passed as an argument or can be returned by another function.
A programming language is said to have First-class functions when functions in that language are treated like any other variable. For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable.
Functional programming languages, such as Erlang, Scheme, ML, Haskell, F#, and Scala, all have first-class functions. When Lisp, one of the earliest functional languages, was designed, not all aspects of first-class functions were then properly understood, resulting in functions being dynamically scoped.
First-class functions are functions that can be treated like any other value. You can pass them to functions as arguments, return them from functions, and save them in variables.
In an ideal world where there was never a cost associated with developing new features, the only downside I can see to including functional programming techniques would be confusion to developers who are not familiar with functional techniques (and I don't really see that as much of a downside).
In reality, treating functions as first-class typically requires significant rewrites to the compiler itself. The cost of doing this has to be weighed against the long-term gain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With