Functional programming is a paradigm which attempts to solve computational problems by the chained evaluation of functions whose output is determined by their inputs rather than the programme state. In this style of programming, side effects and mutable data are deprecated and usually strictly ...
105
votes
15answers
46k views
What is the advantage of currying?
I just learned about currying, and while I think I understand the concept, I'm not seeing any big advantage in using it.
As a trivial example I use a function that adds two values (written in ML). ...
74
votes
6answers
14k views
Functional Programming vs. OOP
I've heard a lot of talk about using functional languages such as Haskell as of late. What are some of the big differences, pros and cons of functional programming vs. object-oriented programming?
59
votes
2answers
8k views
What is the “Free Monad + Interpreter” pattern?
I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement ...
58
votes
11answers
5k views
“Everything is a Map”, am I doing this right?
I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in ...
53
votes
4answers
5k views
what is the purpose of arrows?
I am learning functionnal programming with Haskell, and I try to grab concepts by first understanding why do I need them.
I would like to know the goal of arrows in functional programming languages. ...
46
votes
4answers
3k views
How do functional languages handle random numbers?
What I mean about that is that in nearly every tutorial I've read about functional languages, is that one of the great things about functions, is that if you call a function with the same parameters ...
46
votes
5answers
4k views
In functional programming, does having most of the data structures immutable require more memory usage?
In functional programming since almost all data structure are immutable, when the state has to change a new structure is created. Does this mean a lot more memory usage? I know the object oriented ...
44
votes
12answers
8k views
Why isn't functional programming more popular in the industry? Does it catch on now? [closed]
During my four years at university we have been using much functional programming in several functional programming languages. But I have also used much object oriented programming to, and in fact I ...
44
votes
3answers
6k views
What are the biggest differences between F# and Scala?
F# and Scala are both functional programming langugages that don't force the developer to only use immutable datatypes. They both have support for objects, can use libraries written in other languages ...
44
votes
3answers
12k views
Can somebody explain me what are lambda things in programming? [closed]
So far I heard about :
Lambda calculus
Lambda programming
Lambda expressions
Lambda functions
Which all seems to be related to functional programming...
Apparently it will be integrated into ...
43
votes
12answers
5k views
What programming language generates fewest hard-to-find bugs? [closed]
What language, in your opinion, allows the average programmer to output features with the least amount of hard-to-find bugs? This is of course, a very broad question, and I'm interested in very broad ...
43
votes
14answers
4k views
Why the current enthusiasm for Functional Programming? [closed]
I've been hearing a lot of enthusiasm about functional programming languages lately, with regards to Scala, Clojure, and F#. I've recently started studying Haskell, to learn the FP paradigm.
I love ...
43
votes
6answers
13k views
Where are all the functional programming design patterns? [closed]
OO programming literature is full of design patterns. Most books on object oriented programming dedicate a chapter or two to design patterns like factories and decorators. So what are the equivalent ...
41
votes
5answers
4k views
Critique of the IO monad being viewed as a state monad operating on the world
The IO monad in Haskell is often explained as a state monad where the state is the world. So a value of type IO a monad is viewed as something like worldState -> (a, worldState).
Some time ago I ...
40
votes
7answers
5k views
Are small amounts of functional programming understandable by non-FP people? [closed]
Case: I'm working at a company, writing an application in Python that is handling a lot of data in arrays. I'm the only developer of this program at the moment, but it will probably be ...
39
votes
2answers
6k views
What did Alan Kay mean by “assignment” in The Early History of Smalltalk?
I have been reading The Early History of Smalltalk and there are a few mentions of "assignment" which make me question my understanding of its meaning:
Though OOP came from many motivations, two ...
36
votes
10answers
8k views
Why are side-effects considered evil in functional programming?
I feel that side effects are a natural phenomenon. But it is something like taboo in functional languages. What are the reasons?
Edit: My question is specific to functional programming style. Not all ...
36
votes
9answers
4k views
Real world pitfalls of introducing F# into a large codebase and engineering team [closed]
I'm CTO of a software firm with a large existing codebase (all C#) and a sizable engineering team. I can see how certain parts of the code would be far easier to write in F#, resulting in faster ...
36
votes
1answer
3k views
Why (or why not) are existential types considered bad practice in functional programming?
What are some techniques I might use to consistently refactor code removing the reliance on existential types? Typically these are used to disqualify undesired constructions of your type as well as to ...
35
votes
7answers
14k views
Haskell AND Lisp vs. Haskell OR Lisp [closed]
I currently code with C, C++, and Python. I'm wanting to pick up a functional programming language, and right now I'm leaning toward Haskell. I do NOT want to start a "Haskell vs Lisp" war here; what ...
35
votes
7answers
10k views
Is Functional Programming possible in Java?
I was browsing through the Amazon.com Bookstore and I came across the book "Functional Programming for Java Developers".
I know some very basic Functional Programming and have been programming in ...
35
votes
7answers
6k views
Functional Programming on the rise?
I have noticed lately that functional programming languages are gaining popularity. I recently noticed how the Tiobe Index shows an increase in their popularity in comparison to the last year although ...
33
votes
5answers
12k views
What is the difference between a function and a lambda?
I'm a little bit confused about 'function' and 'lambda'. I've seen some examples showing that the scheme keyword lambda works very similarly to the JavaScript keyword function, but I really don't ...
33
votes
2answers
3k views
Misconceptions about purely functional languages?
I often encounter the following statements / arguments:
Pure functional programming languages do not allow side effects (and are therefore of little use in practice because any useful program does ...
32
votes
9answers
4k views
Why would a program use a closure?
After reading many posts explaining closures here I'm still missing a key concept: Why write a closure? What specific task would a programmer be performing that might be best served by a closure?
...
31
votes
18answers
6k views
What would you do if your client required you not to use object-oriented programming?
I am writing a program to simulate the activity of ants in a grid (PDF). The ant can move around, pick up things and drop things.
The problem is while the action of the ants and the positions of each ...
31
votes
11answers
12k views
Scheme vs Haskell for an Introduction to Functional Programming?
I am comfortable with programming in C and C#, and will explore C++ in the future. I may be interested in exploring functional programming as a different programming paradigm. I am doing this for fun, ...
31
votes
7answers
2k views
Why Functional Programming
What is the deal with functional programming? I see talk about it a lot but to be honest I've never found them at all useful. Why do so many universities apparently teach them?
31
votes
2answers
1k views
What is the meaning of “doesn't compose”?
I see a lot of texts, especially functional programming texts, claim that certain CS concepts "don't compose". Examples are: locks don't compose, monads don't compose.
I've been having a hard time ...
31
votes
2answers
2k views
Why did the Haskell committee choose monads to represent I/O?
The Clean language uses uniqueness types to handle I/O in a purely functional setting. Why did the Haskell committee go with monads instead? Were there other proposals for handling state that the ...
30
votes
6answers
6k views
Why do programs use call stacks, if nested function calls can be inlined?
Why not have the compiler take a program like this:
function a(b) { return b^2 };
function c(b) { return a(b) + 5 };
and convert it into a program like this:
function c(b) { return b^2 + 5 };
...
30
votes
5answers
3k views
Why do some functional programming languages use a space for function application?
Having looked at some languages for functional programming, I always wondered why some fp-languages use one or more whitespace characters for function application (and definition), whereas most (all?) ...
30
votes
7answers
3k views
Is Haskell's type system an obstacle to understanding functional programming? [closed]
I'm studying Haskell for the purpose of understanding functional programming, with the expectation that I'll apply the insight that I gain in other languages (Groovy, Python, JavaScript mainly.)
I ...
30
votes
6answers
16k views
Choosing a functional programming language [closed]
I have read a lot of threads about functional programming languages lately (almost in the past year, in fact). I would really like to pick one and learn it thoroughly.
Last [course] semester, I have ...
30
votes
7answers
15k views
What is a “side effect?”
I haven’t clearly understood the concept of side effect.
What is side effect in programming?
Is it programming language dependent?
Is there such a thing as external and internal side effects?
...
30
votes
2answers
3k views
Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?
In a blog post on F# for fun and profit, it says:
In a functional design, it is very important to separate behavior from
data. The data types are simple and "dumb". And then separately, you
...
29
votes
3answers
4k views
What is the origin and meaning of the phrase “Lambda the ultimate?”
I've been messing around with functional programming languages for a few years, and I keep encountering this phrase. For example, it is a chapter of "The Little Schemer, which certainly predates the ...
27
votes
5answers
4k views
Does immutability entirely eliminate the need for locks in multi-processor programming?
Part 1
Clearly Immutability minimizes the need for locks in multi-processor programming, but does it eliminate that need, or are there instances where immutability alone is not enough? It seems to ...
27
votes
5answers
6k views
Workaround for Java checked exceptions
I appreciate a lot the new Java 8 features about lambdas and default methods interfaces. Yet, I still get bored with checked exceptions. For instance, if I just want to list all the visible fields of ...
26
votes
6answers
4k views
Does learning a functional language make a better OOP programmer? [closed]
As a Java/C#/C++ programmer I hear a lot of talk about functional languages, but have never found a need to learn one. I've also heard that the higher level of thinking introduced in functional ...
26
votes
10answers
2k views
How would Functional Programming proponents answer this statement in Code Complete?
On page 839 of the second edition, Steve McConnell is discussing all the ways that programmers can "conquer complexity" in big programs. His tips culminate with this statement:
"Object-oriented ...
26
votes
3answers
3k views
Different ways to see a monad
While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the ...
25
votes
7answers
1k views
Should one comment differently in functional languages?
I'm just getting started with functional programming and I'm wondering about the correct way to comment my code.
It seems a little redundant to comment a short function as the names and signature ...
25
votes
3answers
3k views
What is referential transparency?
I have seen that in imperative paradigms
f(x)+f(x)
might not be the same as:
2*f(x)
But in a functional paradigm it should be the same. I have tried to implement both cases in Python and Scheme, ...
25
votes
5answers
2k views
What is it about functional programming that makes it inherently adapted to parallel execution? [duplicate]
I've been reading over and over that functional languages are ideal (or at least very often useful) for parallelism. Why is this? What core concepts and paradigms are typically employed and which ...
25
votes
1answer
712 views
Performance of single-assignment ADT oriented code on modern CPUs
Working in immutable data with single assignments has the obvious effect of requiring more memory, one would presume, because you're constantly creating new values (though compilers under the covers ...
24
votes
6answers
3k views
Functional programming compared to OOP with classes
I have been interested in some of the concepts of functional programming lately. I have used OOP for some time now. I can see how I would build a fairly complex app in OOP. Each object would know how ...
24
votes
3answers
4k views
What are combinators and how are they applied to programming projects? (practical explanation)
What are combinators?
I'm looking for:
a practical explanation
examples of how they are used
examples of how combinators improve the quality/generality of code
I'm not looking for:
explanations ...
24
votes
3answers
2k views
Why do some functional languages need software transactional memory?
Functional languages, by definition, should not maintain state variables. Why, then, do Haskell, Clojure, and others provide software transactional memory (STM) implementations? Is there a conflict ...
23
votes
6answers
4k views
Is functional programming a superset of object oriented?
The more functional programming I do, the more I feel like it adds an extra layer of abstraction that seems like how an onion's layer is- all encompassing of the previous layers.
I don't know if this ...