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

learn more… | top users | synonyms (1)

9
votes
4answers
5k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
-4
votes
0answers
65 views

What are recent trends in functional programming language design? [on hold]

I noticed that recent C++-like programming languages like Go, Rust and Swift have some similar improvements regarding type inference, handling of null values, concurrency, syntax, etc, so there is ...
1
vote
3answers
73 views

Using delegates to avoid duplicate creation of resources

I'm writing a PCL that uses an HttpClient to go visit a few sites and extract data from them. My initial code looked like this: public static class Download { public async static ...
2
votes
2answers
171 views

How do I make this functional DSL written in an imperative language more efficient?

Suppose I create a simple functional Domain-specific language (DSL) using an imperative language, in this case C++. Here is a simple implementation of a DSL that can has the notion of a simple value ...
27
votes
7answers
13k 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? ...
3
votes
2answers
802 views

How is intermediate data organized in MapReduce?

From what I understand, each mapper outputs an intermediate file. The intermediate data (data contained in each intermediate file) is then sorted by key. Then, a reducer is assigned a key by the ...
0
votes
3answers
406 views

Is functional language without runtime written in C possible? [on hold]

Every functional language that compiles to native code relies on quite big runtime written in C programming language (well at least ones that I know of, for example Haskell, OCaml, Gambit/Chicken ...
2
votes
0answers
40 views

How to handle complex calculated fields in an ORM

In our API we've got a few central datatypes which need to be "decorated" (so to speak) after retrieval from the database with calculated values. The database is accessed through an ORM which follows ...
-3
votes
0answers
36 views

Fastest way to gather Provider data [closed]

What's the most efficient and quickest way of mining medical providers data in order to list them under a website and categorize them by city and state? Is it through an algorithm?
5
votes
3answers
210 views

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 ...
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? ...
15
votes
3answers
2k views

What problem do algebraic data types solve?

Fair warning, I'm new to functional programming so I may hold many bad assumptions. I've been learning about algebraic types. Many functional languages seem to have them, and they are fairly useful ...
29
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 }; ...
14
votes
5answers
907 views

Is the semantic contract of an interface (OOP) more informative than a function signature (FP)?

It is said by some that if you take SOLID principles to their extremes, you end up at functional programming. I agree with this article but I think that some semantics are lost in the transition from ...
2
votes
1answer
412 views

Local Updates in Persistent/Immutable Data Structures

I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing ...
4
votes
2answers
125 views

Are (basic) SQL queries semantically equivalent to Higher Order Functions?

Is SQL basically a domain specific instance of map + fold + filter? It seems to me that the following SQL: SELECT name FROM fruits WHERE calories < 100 is just syntactic sugar for the ...
8
votes
2answers
233 views

Is it common practice to transform requirement specifications into predicate logic for functional programming?

I've recently been assigned to work on a small project which is being implemented in Haskell. Coming from an OO/imperative background, I'm used to converting requirements/user-stories into use-cases ...
8
votes
1answer
162 views

Is it possible to have currying and variadic function at the same time?

I am thinking about making currying and variadic functions both available in a dynamically-typed functional programming language, but I wonder if it is possible or not. Here are some pseudocode: sum ...
13
votes
2answers
608 views

What is Banana split and fusion in functional programming?

These terms got mentioned in my university course. Quick googling pointed me to some university papers, but I am looking for a simple explanation.
9
votes
2answers
372 views

Maintaining State without assignment

I am learning functional programming and I have trouble understanding how some particular scenarios are implemented without the use of assignment. The following simple problem pretty much sums up my ...
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?
42
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 ...
25
votes
5answers
5k 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 ...
5
votes
2answers
353 views

Is the application architecture of Facebook Flux a new idea?

Facebook announced that it's using the architecture they call Flux to develop their projects. It consists of a single direction dataflow, and concepts like a Dispatcher, Stores and Actions (well ...
1
vote
2answers
102 views

distinguish requests from the same vehicle

I am implementing an small app to track buses based on Crowdsorcing. The riders send data long, lat, mac, route to the server as JSON string. In my database I have table bus to insert the transmitted ...
15
votes
3answers
3k views

Ur/Web new purely functional language for web programming? [closed]

I came across the Ur/Web project during my search for web frameworks for Haskell-like languages. It looks like a very interesting project done by one person. Basically, it is a domain-specific purely ...
1
vote
1answer
84 views

Are There Tools for Statically Evaluating C++ Functions for Side Effects? [closed]

I'm interested in having a tool that can evaluate whether a function in C++ has side effects. I'd like to be able to mark functions as having or not having side effects, which I think would make ...
1
vote
1answer
203 views

Why can a constructor be used without `new` keyword in Javascript?

I found Date can be used without the new keyword. Date(1) > "Thu May 28 2015 15:54:20 GMT+0800 (CST)" new Date(1) > Thu Jan 01 1970 08:00:00 GMT+0800 (CST) I was wondering whether there is ...
4
votes
2answers
121 views

Functional Programming - Functions defining specific evaluation of functions passed to it for optimization

Firstmost, I am just getting started with functional programming so I would appreciate corrections in any terminology I may have used incorrectly. Story time, While doing a Project Euler Problem 1 in ...
7
votes
4answers
325 views

What makes functional programming languages declarative as opposed to Imperative?

On many articles, describing the benefits of functional programming, I have seen functional programming languages, such as Haskell, ML, Scala or Clojure, referred to as "declarative languages" ...
4
votes
2answers
154 views

How to design for good abstractions using algebraic data type?

Every now and then I have peaked at Haskell Tutorials and found the Algebraic data types quite interesting. I took their purpose to be to represent types that have completely separable states. Sadly, ...
6
votes
3answers
170 views

What is the functional programming answer to type-based invariants?

I am aware that the concept of invariants exists across multiple programming paradigms. For example, loop invariants are relevant in OO, functional and procedural programming. However, one very ...
56
votes
3answers
7k 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 ...
13
votes
5answers
858 views

Can *any* program task be expressed without state?

This is a theoretical question, but after many years of programming in what I now realize is "normal" imperative technique, using C++ mainly, I've discovered this other world of functional ...
10
votes
5answers
691 views

Can a pure-functional solution to this problem be as clean as the imperative?

I have an exercise in Python as follows: a polynomial is given as a tuple of coefficients such that the powers are determined by the indexes, e.g.: (9,7,5) means 9 + 7*x + 5*x^2 write a function to ...
12
votes
5answers
2k views

What are functional-programming ways of implementing Conway's Game of Life [closed]

I recently implemented for fun Conway's Game of Life in Javascript (actually coffeescript but same thing). Since javascript can be used as a functional language I was trying to stay to that end of ...
18
votes
1answer
612 views

Using uniqueness types to implement safe parallelism

I've been interested in uniqueness types as an alternative to monads in pure functional languages for some time; unfortunately, this is kind of an esoteric area of CS research and online resources ...
20
votes
3answers
2k views

How do purely functional programming languages deal with fast changing data?

What data structures can you use so you can get O(1) removal and replacement? Or how can you avoid situations when you need said structures?
14
votes
1answer
2k views

Does Clojure have continuations/coroutines/etc?

I started programming with Python, and I was really confused by concepts like coroutines and closures. Now I think I know them on some superficial level, but I've never felt that "enlightement" ...
29
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 ...
2
votes
1answer
131 views

What is the value of a let expression

From what I understand, every code in f# is an expression, including let binding. Say we got the following code: let a = 5 printfn "%d" a I've read that this would be seen by the compiler as let a ...
3
votes
3answers
349 views

Functional vs object-oriented style in C#

I'm learning functional programming and face the following confusion when applying it to my C# projects: I begin by writing pure, static functions and use function composition. After the code ...
2
votes
1answer
269 views

Should all functions be fully self-contained (is it bad practice to share a variable between functions)?

There are two ways to do the same thing (pseudo code) Define databaseHandle in the parent function, and use it as a global in this scope: function API() { function openDatabase() { ...
1
vote
1answer
266 views

What aspects of Haskell led to its rise in popularity among experts?

20 years ago, the Functional Programming world was all about Lisp and Scheme. When I went to college in 2001, my Fall Semester Freshman CS 101 course was taught in OCaml. However, these days the ...
30
votes
11answers
11k 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, ...
0
votes
1answer
113 views

Haskell types for functions

I don't understand the answer to this question: Q: Can Haskell find a type for the function selfapply defined by: selfapply f = f f A: The function selfapply is not typeable in the simple system of ...
21
votes
6answers
3k views

how a pure functional programming language manage without assignment statements?

When reading the famous SICP, I found the authors seem rather reluctant to introduce the assignment statement to Scheme in Chapter 3. I read the text and kind of understand why they feel so. As ...
22
votes
7answers
2k views

Does functional programming ignore the benefits gained from the “On the Criteria To Be Used in Decomposing Systems into Modules” (data hiding)?

There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles ...
1
vote
1answer
241 views

What is the “->” symbol called?

I have seen the -> operator/symbol in Java 8 predicates recently and wondered what its name is. I know that it is used in lambda expressions, but I know that the symbol for lambda is λ, so that's ...
2
votes
2answers
104 views

Dealing with states in a immutable approach [closed]

I want to know how to deal when you have some states in a program, with functions that depends on them, but with a immutable approach. I read some examples and questions, but all focus in a small ...