Questions tagged [scala]

Scala is a general purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way, it fuses both imperative and functional programming styles.

239 questions
76
votes
3 answers

What is the difference between a Future and a Promise?

What is the difference between a Future and a promise? (In Akka and Gpars.) They look the same to me as both block and return the value of the future when get is called and a promise is to get the result of a future.
74
votes
4 answers

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 and run on a virtual machine. Both languages…
Jonas
  • 14,867
  • 9
  • 69
  • 102
71
votes
8 answers

How do you encode Algebraic Data Types in a C#- or Java-like language?

There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as: data ConsList a = Empty | ConsCell a (ConsList a) consmap f Empty = Empty consmap f (ConsCell a b) =…
Jörg W Mittag
  • 101,921
  • 24
  • 218
  • 318
69
votes
4 answers

Is functional programming faster in multithreading because I write things differently or because things are compiled differently?

I'm diving into the world of functional programming and I keep reading everywhere that functional languages are better for multithreading/multicore programs. I understand how functional languages do a lot of things differently, such as recursion,…
Aventinus
  • 801
  • 1
  • 7
  • 10
68
votes
5 answers

When is it NOT good to use actors in akka/erlang?

I've been working with akka for 7-8 months now daily. When I started, I would be working on applications and notice that actors would be used basically anywhere once inside the actor system for communicating between most objects. So I did the same -…
JasonG
  • 1,129
  • 1
  • 10
  • 14
55
votes
3 answers

What are the advantages of Scala's companion objects vs static methods?

Scala has no static-keyword, but instead has similar functionality through companion objects. Behind the scenes the companion objects are compiled to classes that have static methods, so all this is syntactic sugar. What are the advantages of this…
Zavior
  • 1,334
  • 2
  • 11
  • 18
42
votes
12 answers

Why do most programming languages have special keyword or syntax for declaring functions?

Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see functions as just as declaring another named…
pathikrit
  • 570
  • 5
  • 8
41
votes
9 answers

Is memory management in programming becoming an irrelevant concern?

Background I revisited an old (but great) site I had not been to for ages - the Alioth Language Shootout (http://benchmarksgame.alioth.debian.org/). I started out programming in C/C++ several years ago, but have since then been working almost…
csvan
  • 551
  • 4
  • 7
41
votes
4 answers

Performance of Scala compared to Java

First of all I would like to make it clear that this is not a language-X-versus-language-Y question to determine which is better. I have been using Java for a long time and I intend to keep using it. Parallel to this, I am currently learning Scala…
Giorgio
  • 19,486
  • 16
  • 84
  • 135
38
votes
4 answers

What limitations does the JVM impose on tail-call optimization

Clojure does not perform tail call optimization on its own: when you have a tail recursive function and you want to have it optimized, you have to use the special form recur. Similarly, if you have two mutually recursive functions, you can optimize…
Andrea
  • 5,355
  • 4
  • 31
  • 36
37
votes
4 answers

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 general. I've been looking for the ORM by default…
gabrielgiussi
  • 1,326
  • 1
  • 11
  • 10
36
votes
7 answers

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 to do things that object does. Or anything it's…
skift
  • 685
  • 2
  • 8
  • 14
36
votes
6 answers

Re-inventing system design for Scala

Many, many, moons ago, I did my masters in Object Orientated Software Engineering. I covered everything: project initiation, requirements, analysis, design, architecture, development, etc, etc. My favourite IT book of all time was Developing Object…
Jack
  • 507
  • 4
  • 11
33
votes
5 answers

If Scala runs on the JVM, how can Scala do things that Java seemingly cannot?

I just learned about Scala yesterday, and I'd like to learn more about it. One thing that came to mind, however, from reading the Scala website is that if Scala runs on the JVM, then how is it possible for bytecode compiled from Scala source to be…
Mirrana
  • 1,037
  • 2
  • 12
  • 20
31
votes
3 answers

What are the benefits and disadvantages in the approaches of C#, Java and Scala to Closures/Lambdas/...?

I wonder what the technical implementation differences between C# and Scala are and how both solutions compare to the implementation ideas and concerns voiced in the email Peek Past lambda by Brian Goetz, sent to the mailing list of Project Lambda…
soc
  • 381
  • 4
  • 10
1
2 3
15 16