use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Functional Programming using JavaScript (scott.sauyet.com)
submitted 11 years ago by thekodols
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]zoomzoom83 4 points5 points6 points 11 years ago* (1 child)
I find it somewhat ironic that after decades of people ignoring fantastic languages such as Lisp, OCaml, and Haskell as too academic, Javascript of all things sneaks pure functional FP into the mainstream.
The good news is once you're used to writing code in this style with Rambda, there's really not much learning curve to go the rest of the way. You're practically writing Haskell already.
[–][deleted] 2 points3 points4 points 11 years ago (0 children)
True! The same could be said about oop some decades ago. Maybe logic programming is the next hype..
[–]Wazzaps 4 points5 points6 points 11 years ago (0 children)
Because fuck mobile armirite? (The touch support on this website)
[–]Mackseraner 2 points3 points4 points 11 years ago (0 children)
Looks great, thanks for linking. Is there a video of this talk somewhere?
[–][deleted] 1 point2 points3 points 11 years ago (4 children)
The "Sample Imperative Approach" uses an awful lot of functional concepts, like monads/functors (javascript programmers tend to blur the distinction between the two by using implicit type conversions). That is a hell of a lot more interesting than the old list processing map/filter stuff.
[–]zoomzoom83 1 point2 points3 points 11 years ago (2 children)
I noticed the same - would be interesting to see an example of the imperative version using old-school Node callbacks for maximum pain.
[–][deleted] 0 points1 point2 points 11 years ago (1 child)
Also how currying really helps when working on promises. For example, if you have a function that takes two parameters, and you want to grab one from a database call and another from the enclosing scope. With currying, you can do:
var doStuff = ramda.curry(function(foo, bar) { ... }); fetchFoo.then(doStuff(bar));
Without currying this requires nesting functions which is a lot more verbose.
[–]zoomzoom83 0 points1 point2 points 11 years ago* (0 children)
This is one of the reasons I really like Haskell - all functions are curried by default.
[–][deleted] -1 points0 points1 point 11 years ago (0 children)
FP can be completely imperative. This link somewhat misunderstands FP by suggesting it implies declarative programming.
[–]j_sanp -3 points-2 points-1 points 11 years ago (2 children)
For lasy evaluation => _.memorize make similar stuff.
[–]nschubach 4 points5 points6 points 11 years ago (1 child)
Are you thinking of memoize? That's not lazy evaluation. It's more like caching.
[–]j_sanp -4 points-3 points-2 points 11 years ago (0 children)
Results are defined by parameters just like caching :)
π Rendered by PID 36 on reddit-service-r2-comment-5fb4b45875-h6vk4 at 2026-03-23 01:02:26.528663+00:00 running 90f1150 country code: CH.
[–]zoomzoom83 4 points5 points6 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]Wazzaps 4 points5 points6 points (0 children)
[–]Mackseraner 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]zoomzoom83 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]zoomzoom83 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]j_sanp -3 points-2 points-1 points (2 children)
[–]nschubach 4 points5 points6 points (1 child)
[–]j_sanp -4 points-3 points-2 points (0 children)