3 ms·
We can also create objects from closures and classes from functions, so why have syntax for it? Some languages have some of the feature I mentioned, JavaScript
by ilovecaching 8y ago
We can also create objects from closures and classes from functions, so why have syntax for it?
Some languages have some of the feature I mentioned, JavaScript has bind for example, but it’s cumbersome and using it as a means of partial application for FP would be an abuse.
These operators need to be syntactically easy to use, ergonomic, and recommended. Notice that in Haskell these are infix for a reason.
Also, in typed languages with generics building those operators is more tricky.
- yunyu 8y agoThere is currently a proposal to bring syntax support for partial application to JS: https://github.com/tc39/proposal-partial-application/blob/master/README.md https://github.com/tc39/proposal-partial-application/blob/ma...
- lkitching 8y agoBut the reason Javascript isn't a functional language is because its built-in data structures are all mutable which encourages an imperative style, not because its functions are tupled or it lacks a function composition operator. I agree syntax is important, but your definition rules out languages like Clojure which most people would consider functional. Haskell programmers might disagree, but I would assume on the grounds of purity rather than the syntactic overhead of partial application.
- bgorman 8y agoSyntax is not the core of functional programming, semantics are. Lambdas are all that is necessary to express functional programming. Notice how both Clojure and Haskell feature a lambda in their logos.