4 ms·
> you really can’t do FP without automatic currying and the function composition and application operators (. And $) in Haskell But lambdas are enough to defin
by lkitching 8y ago
> you really can’t do FP without automatic currying and the function composition and application operators (. And $) in Haskell
But lambdas are enough to define these operators e.g.
(defn comp [f g] (fn [x] (f (g x)))
(defn ap [f x] (f x))
Operators and currying by default can use useful but it's a syntactic issue rather than a fundamental one.
- danharaj 8y agoProgrammers work with syntax. If syntax is cumbersome, programmers are inefficient. Syntax should be optimized for what the language wants you to do. Languages that just bolt on lambdas seldom are optimized to use them effectively. They're optimized for some other abstractions.
- yogthos 8y agoWe are talking about a Lisp here...
- danharaj 8y agoThe OP was making a semantic point. Take their example and write it in Python and imagine trying to actually work with it. I partially applied a function in Python once. Sucked.
- yogthos 8y agoSure, in a language where you can't easily extend semantics they have to be baked into the language to be practical. However, with Lisps you can trivially create new semantics as you need them, and whenever something becomes cumbersome it can be addressed by the user as the need arises.
- ilovecaching 8y agoWe 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.
- deleted 8y ago[deleted]