Skip to main content

All Questions

0 votes
2 answers
300 views

Trying to understand how this class representation truly represents Natural numbers in Scala

Following Martin Odersky's course on coursera - Functional Programming with Scala and I'm on Week 4 where we're learning about Types and Pattern Matching. In the video lecture, this is the ...
1 vote
3 answers
442 views

Scala Option vs. conditional branches

If I'm writing Scala functions and have to check for nulls in situations where I can't avoid it (say, working with Spark UDFs and some legacy Java types), is it better to turn things into Option or to ...
75 votes
4 answers
16k 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 ...
19 votes
3 answers
21k views

Fastest Functional Language

I've recently been delving into functional programming especially Haskell and F#, the prior more so. After some googling around I could not find a benchmark comparison of the more prominent functional ...
36 votes
7 answers
12k 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 ...
5 votes
7 answers
628 views

Do non-pure interpreters still make the guarantees of functional programming?

I am assuming the implementations/compilers/generated C code (referred to hereinafter as generic, 'interpreter') for most functional programming languages are written in non-pure functional languages. ...
3 votes
1 answer
410 views

Dependencies between functions-only modules: hardcoding vs alternatives

In switching from a procedural background to "FP in the small, OO in the large" I'm grappling with the following problem. Suppose there're modules, each only containing numerical math functions ...
1 vote
2 answers
140 views

How can an iterative algorithm be controlled dynamically?

Suppose we need an iterative algorithm for mathematical optimisation. Each iteration takes a long and random time. After each iteration, a stopping condition is checked for the iterate x, based on ...
5 votes
1 answer
852 views

Is using Option#get really a bad idea here?

I'm working on a Scala project and Wartremover shows an error about Option#get usage in my code: Option#get is disabled - use Option#fold instead While I do understand how get should often be avoided,...
1 vote
1 answer
1k views

Does dependency injection fly in the face of functional programming?

I have the following pure function (f2 and f3 are pure too): class X { def f1(arg: Type1): Type2 = { val x = f2(arg) val y = f3(x) y } def f2... def f3... } Now, I would like ...
12 votes
1 answer
8k views

Pattern matching in Clojure vs Scala

What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity. Scala ...
37 votes
4 answers
22k views

Why would I not need an ORM in a functional language like Scala?

I'm wondering if I can switch from Java to Scala in a Spring + Hibernate project to take advantage of some Scala features such as pattern matching, Option and what it seems to me a cleaner syntax in ...
1 vote
1 answer
117 views

Simplified API one case class vs robust and multi ADT case class? [duplicate]

Below are oversimplified examples, but I wonder which route to take what is the best practice when designing API, the simple or the more complex and robust which is better? This looks good and goes ...
1 vote
1 answer
420 views

Modelling relational database entities in a functional language

I'm working on a Scala project that uses DynamoDB for persistence, and does this by modelling the records as case classes. This is becoming increasingly more relational, which means we have classes ...
3 votes
2 answers
227 views

functional programming: impact of typedef-ing datatypes on code readability and maintenance

In functional programming languages, such as Scala, data types and structures, are really important. I am in two minds about the use of type-defs in helping with the readability of the code ...

15 30 50 per page