DEV Community

Cover image for Currying

Currying

James Robb on March 16, 2020

In mathematics and computer science, currying is a way of splitting a function which takes multiple arguments into a sequence of functions that tak...
Collapse
 
gregfletcher profile image
Greg Fletcher

Nice! Do you often use functional programming in your normal daily programming?
I personally prefer functional programming when possible but I'm always interested to hear what people like about it For me, a couple of the benefits of functional programming are the readability of the code and also the removal of boilerplate.

Collapse
 
jamesrweb profile image
James Robb

I try to use it as often as possible but working with different clients means that sometimes their systems are in OOP languages or some other paradigm and so using FP isn't always possible. It is something I find easier to reason with though personally since I aim to break any task down to the basics and this maps well with FP in my opinion. All I need to do is compose each task/action together to have the desired outcome and so using something like the compose function or pipe function is very useful in such scenarios.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I am very interested in adopting functional programming, for one simple reason: functions, being free of side effects, are easier to reason about and verify. The type of things I create benefit greatly from this attribute!

Collapse
 
jamesrweb profile image
James Robb

Agreed, it can give you a lot of freedom but other paradigms bring benefits of their own, it's really a balance always but if you keep functions simple and work them together logically it can work out pretty well for all involved.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I agree! I don’t think switching exclusively is beneficial enough to do for exactly the reasons you stated, but I would benefit from using the ideas where they make sense.

Thread Thread
 
jamesrweb profile image
James Robb

Exactly and if you can break all tasks into small pieces, there's no reason why all your work couldn't just be function compositions but of course we don't live in such an ideal world although in a lot of cases it is feasible to do.

Collapse
 
eljayadobe profile image
Eljay-Adobe

I had commented on another currying article on Dev.to over here, dev.to/eljayadobe/comment/o3p

Currying in JavaScript is "meh".
Currying in C++ is "omg, ow ow ow".
Currying in F# is "ahhh, nerdvana".

Collapse
 
jamesrweb profile image
James Robb

Absolutely 😂

Collapse
 
thatonejakeb profile image
Jacob Baker

Slightly off-topic, but it is way to close to dinner time for this to keep going to the top of my feed and showing me a huge picture of a curry!

Collapse
 
jamesrweb profile image
James Robb

I felt the same and actually just ordered food not that long ago 😅