2 ms·
> functions are first class objects Programming languages have procedures, not functions. (Yes, even Haskell. Consider the possibility of divergence.) Function
by catnaroek 10y ago
> functions are first class objects
Programming languages have procedures, not functions. (Yes, even Haskell. Consider the possibility of divergence.) Functional programming is a style that:
(0) Emphasizes values over physical object identities.
(1) Emphasizes procedures that compute functions - mappings from values from a domain, into values from a codomain.
(2) Discourages distinguishing between procedures that compute the same function.
Functional languages are languages that facilitate and encourage functional programming. Does JavaScript? IMO, it doesn't even do (0) very well, which is a precondition for discussing whether it does (1) or (2) well.
> garbage collector, persistent data structures
Don't conflate “purely functional” with “persistent”. Purely functional programming can deal with ephemeral data structures just fine - using substructural types. In the other direction, there exist persistent data structures whose implementation internally uses imperative assignment.
> powerful and flexible
Those are desirable qualities in a language, but they are orthogonal to whether the language supports functional programming.
> express all of these ideas in an accessible way
JavaScript doesn't even make it easy to talk about structurally equal values. Since everything is mutable, the only notion of equality that the language will actually respect is equality of physical object identities.
Without the ability to talk (soundly) about structural value equality, you can't formulate algebraic laws (e.g., the monoid or group laws), which is the basis for equational reasoning - one of the key benefits of programming in a functional style!