DEV Community

Discussion on: Functional programming in python

 
aswinbarath profile image
Aswin Barath

@cappe987
Casper, before making strong opinions and extreme use-case on Functional programming being not memory efficient, please look at the big picture.

When you write through functional programming, you store less information right?
You say that - "You are right that less code means less memory. But in terms of code size it may only be a few hundred bytes and should be the least of your concerns, especially since using functions is something you should do anyways."

But, consider a big project which has millions or billions of lines of code in its codebase, at those times you get to reduce a lot of memory in an exponential rate.

Thread Thread
 
cappe987 profile image
Casper

I'm well aware how FP concepts can be applied in non-FP languages. I never said anything against pure functions in Python (I just pointed out that map/filter/reduce aren't inherently pure as the purity depends on the function passed, I wasn't discrediting the use of them) But you talked about using functions to reduce code duplication as an FP concept when it's not. It's a concept of programming in general.

when I say FP code is being more memory efficient I mean that
when we start to use functions we are reducing the number of repetitions in our code

You could remove the "FP" from the quote above and it would still hold true.

Thread Thread
 
aswinbarath profile image
Aswin Barath

OK, got it