Questions tagged [functional-programming]

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 isolated.

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 isolated.

The disciplines of functional programming can be applied in almost any language, but in many imperative languages the resulting code is inelegant and verbose. A growing set of programming languages have been developed explicitly to enable expressive functional coding, including

  • Lisp, with its many dialects (e.g. Common Lisp, Scheme, Clojure)
  • ML/SML/OCaml
  • Haskell
  • Scala
  • Erlang
737 questions
71
votes
5 answers

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 programming paradigm well, now I'm trying to learn…
Jbemmz
  • 812
  • 1
  • 6
  • 9
65
votes
12 answers

Why isn't functional programming more popular in the industry? Does it catch on now?

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 use object oriented languages more when doing my…
Jonas
  • 14,867
51
votes
14 answers

Why the current enthusiasm for Functional Programming?

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 it, it's really fun, and fits my math…
Eric Wilson
  • 12,071
44
votes
2 answers

Why are lists the data structure of choice in functional languages?

Most functional languages use linked lists as their primary immutable data structure. Why lists, and not e.g. trees? Trees can also reuse paths, and even model lists.
43
votes
1 answer

How to organize functional programs

Possible Duplicate: Functional Programming vs. OOP How to write manageable code with functional programming? In OOP, your basic unit of organization for code is the class. A frequently used methodology in Java, C# and similar languages is to…
Gilles
  • 2,201
42
votes
6 answers

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?
user7007
35
votes
5 answers

Why are discriminate unions associated with functional programming?

In many years of OO programming I've understood what discriminated unions are, but I never really missed them. I've recently been doing some functional programming in C# and now I find I keep wishing I had them. This is baffling me because on the…
Andy
  • 687
25
votes
4 answers

Dealing with state problems in functional programming

I've learned how to program primarily from an OOP standpoint (like most of us, I'm sure), but I've spent a lot of time trying to learn how to solve problems the functional way. I have a good grasp on how to solve calculational problems with FP, but…
24
votes
6 answers

In functional programming, are local mutable variables with no side effects still considered "bad practice"?

Is having mutable local variables in a function that are only used internally, (e.g. the function has no side effects, at least not intentionally) still considered "non functional"? e.g. in the "Functional programming with Scala" course style check…
Eran Medan
  • 1,043
21
votes
7 answers

Can functional programming be used to develop a full enterprise application?

I am just beginning to learn Functional programming (FP). I come from a OOP world, where everything are objects, and most of them are mutable. I have a hard time wrapping around the concept that functions don't have side effects. If something is…
user2434
  • 1,277
19
votes
4 answers

What are the benefits of referential transparency to a programmer?

In programming, what are the benefits of referential transparency? RT makes one of the major differences between functional and imperative paradigms, and is often used by advocates of the functional paradigm as a clear advantage over the imperative…
Eyal Roth
  • 603
  • 5
  • 11
14
votes
3 answers

Functional programming and Text adventures

This is mostly a theoretical question about FP, but I'll take text adventures (like old-school Zork) to illustrate my point. I'd like to know your opinions on how would you model a stateful simulation with FP. Text adventures really seem to call for…
13
votes
2 answers

Do compilers like Javac automatically detect pure functions and parallelize them?

Pure functions are known to facilitate parellelizing. What is it about functional programming that makes it inherently adapted to parallel execution? Are compilers such as Javac smart enough to detect when a method is a pure function? One can…
Naveen
  • 139
13
votes
4 answers

Functional Programming - Does Knowing It Help Job Prospects?

The main language that I use at the moment is C# and I am the most comfortable with it. However, I have started dabbling in F# and Haskell and really enjoy those langauges. I would love to improve my skills in either of those languages over time…
Jetti
  • 5,163
12
votes
2 answers

Using queues to decouple functions/avoid direct calling?

Kind of a functional programming newbie question here: I've been reading the transcripts of some of Rich Hickey's talks, and in several of his more well-known ones, he recommends using queues as an alternative to having functions call one another. …
Paul Gowder
  • 223
  • 1
  • 5
1
2 3