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.

learn more… | top users | synonyms

3
votes
2answers
1k views

Learning Scala, feeling discouraged [closed]

I'm coming from a Java background and trying to learn Scala. At the moment I'm feeling pretty overwhelmed, there seems to be so much more to learn with Scala, so many different ways of doing the same ...
0
votes
1answer
171 views

Scala class with constructor requiring parameter of the same Class type

I can't remember but recently in one of the APIs I saw something like this class A (member:A){}. Scala does support it and there is no problem creating such a class but how do we initiate it and what ...
2
votes
6answers
501 views

How do you move beyond code examples without a project?

I am currently learning Scala and I find a mental blog of how to proceed to a degree where I can use Scala daily beyond the normal examples. I just do not have a particular project in mind of what I ...
8
votes
3answers
3k views

Functional Programming approach for a simplified game using Scala and LWJGL

I, a Java imperative programmer, would like to understand how to generate a simple version of Space Invaders based on Functional Programming design principles (in particular Referential Transparency). ...
7
votes
4answers
936 views

Why does Scala use the '_' operator for package import instead of '*' as in Java?

In my opinion, one of the greatest things about Scala is its interoperability with Java and its similar syntax. One thing that I found strange is the use of the _ operator for package wilcard imports ...
1
vote
2answers
227 views

Is short-circuit evaluation a consequence of call-by-name?

If the boolean operators &&, || are implemented as infix methods, then isn't short-circuit evaluation just a consequence of being implemented using call-by-name semantics, since, for example, ...
6
votes
1answer
580 views

Why appending to a list in Scala should have O(n) time complexity?

I am learning Scala at the moment and I just read that the execution time of the append operation for a list (:+) grows linearly with the size of the list. Appending to a list seems like a pretty ...
-6
votes
3answers
699 views

Are Extension methods (C#) and categories (Objective-C) the same as traits? [closed]

According to: Something similar to Objective-C categories in other languages? Static extension methods in C# are basically the same thing as Objective-C categories, so I'm going to lump these two ...
10
votes
2answers
1k views

How is Nothing a subtype of every other type in Scala

I am taking Martin Odersky's coursera course on functional programming with scala, and for now I have learned two things that together don't make sense: Scala doesn't support multiple inheritance ...
2
votes
1answer
457 views

Is there a representation for mixins or traits on UML?

Is there a representation for modern programming constructs that are becoming common in modern OOP/hybrid languages like mixins/traits/categories/partial classes ?
13
votes
1answer
996 views

Scala as a language for Generic Programming

In the paper “An Extended Comparative Study of Language Support for Generic Programming” by Garcia et al. an interesting comparison of programming languages features for generic programming is given: ...
20
votes
8answers
9k views

Why was Scala not implemented with C or C++

Does anybody know why was Scala implemented in Java and .NET instead of C or C++? Most languages are implemented with Cor C++ [i.e Erlang, Python, PHP, Ruby, Perl]. What are the advantages for Scala ...
4
votes
1answer
341 views

What kind of problems is an Android beginner likely to encounter in using Scala?

I am a hobbyist programmer who makes and maintains one production system, largely coded in Python, which now has to be ported to Android. I don't know Java at all. However, SL4A in Android makes ...
-4
votes
2answers
235 views

Am I barking up the wrong tree with Scala? [closed]

Having some spare time, I've decided to learn a new programming language while developing - for fun, will never see the light of day - an insurance administration web application (insurance is the ...
5
votes
2answers
1k views

Node.JS or Scala for mobile and web apps [closed]

I am coming from a php background with some python as well. I want to start working on a different language for both web and mobile development. I am also interested in real time apps dealing with ...
1
vote
2answers
221 views

How to name nested function? [closed]

When you have a function that wraps another one in Scala. What do you call the nested function? I found this : def factorial(i: Int): Int = { def fact(i: Int, accumulator: Int): Int = { if ...
2
votes
3answers
719 views

Does macros support make Scala a Lisp dialect?

I've read recently that macro support in Scala is now official. I checked the documentation page and they are reminiscent to the LISP ones. In one of his essays Paul Graham writes that when "you add ...
2
votes
4answers
271 views

How to promote Scala to the management?

As a developer I like Scala and could tell the management about technical benefits of the language. But even if management understands that a superior technology has business impact, I fear that they ...
2
votes
2answers
1k views

Should I use semicolons to delimit Scala statements?

I'm used to delimit statements by a semicolon from Java, so naturally I do it in Scala code too. I also feel that the code is easier to read, because it's evident where one statement ends and another ...
7
votes
1answer
847 views

Why is the Scala Option type not called Maybe, just as in Haskell?

Why is the Scala Option type not called Maybe, just as in Haskell? Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of. Is there any particular ...
4
votes
4answers
417 views

Big switching from one platform to another [closed]

As an example I want to switch from C#/.NET to Scala/Jvm. I'm working as a self-employed and I'm free to choose my favorite language/platform. Having more than 8 years of experience in C#/.NET leads ...
16
votes
4answers
4k views

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 ...
2
votes
1answer
683 views

Is it worthwile to learn/use Play framework (for Scala or Java) if I don't use the MVC in it

I prefer Single Page Application to server side generated HTML. I am sensible to the pitch of "high productivity" delivered by Play. Now if I don't use the HTML generation part, is it still ...
0
votes
2answers
921 views

How do I initialize a Scala map with more than 4 initial elements in Java?

For 4 or fewer elements, something like this works (or at least compiles): import scala.collection.immutable.Map; Map<String,String> HAI_MAP = new Map4<>("Hello", "World", ...
19
votes
6answers
4k views

Why these attempts to water down Scala with Xtend and Kotlin? [closed]

So now Eclipse has offered Xtend and JetBrains is offering Kotlin - both of which seem to be watered down versions of Scala. My question is why? I've played with Scala a bit and it's not that hard. ...
0
votes
1answer
171 views

Scala string interpolator: ad-hoc feature of general construct?

In Scala 2.10 a new string interpolator feature has been added (see here). For example val name = "James" println(s"Hello, $name") // Hello, James What is not clear to me is whether this feature ...
6
votes
5answers
3k views

Is Clojure's syntax really simpler than Scala's? [closed]

Argument which is always made in favour of Clojure is that. The syntax is simpler and there is only one way of expressing code with no complicated rules. However Scala has loads of different types ...
2
votes
4answers
1k views

What are the practical benefits of LISP like syntax which Clojure uses over Java like syntax of Scala?

I spent couple of months learning Scala and got overwhelmed by number of different constructs it had, After looking at partial functions, partially-applied functions, pattern matching, actor syntax, I ...
4
votes
2answers
273 views

How are Scala Traits implemented in the JVM?

I have been reading about traits in Scala. They are pretty amazing. I am curious how they extend a class without actually resulting in multiple inheritance. I know that the JVM doesn't support ...
34
votes
8answers
3k views

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 ...
32
votes
5answers
15k views

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. ...
26
votes
5answers
13k views

Is Groovy going away? [closed]

I am sure this question has been asked many times. However, I like to ask it again with the intention of what is the future of these languages. I was first introduced to Groovy and really liked it. I ...
2
votes
1answer
1k views

Using akka actors with service spring beans

Do you think that using akka actors in front of transactional service beans, is a good idea ? Actors are waked up by a facade used by a client application, and actor use a message to handle right ...
25
votes
2answers
2k views

Applying Denotational Semantics to design of Programs

I've read a bit on denotational semantics (DS) and I'm very intrigued about the process of designing computer programs where types and functions have strong and clear mappings to mathematics. Are ...
0
votes
1answer
2k views

Method overload in scala

I know method overload is not allowed in Scala and I have read some posts regarding the reasons. But still, I see some functions overloaded in Scala library (example: println). I want to know how it ...
21
votes
3answers
5k views

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 ...
4
votes
3answers
322 views

How do I get feedback about whether escape analysis had any affect on my code or not?

One problem I have with compiler optimization is, that I actually never know what the compiler (or in this particular case the Jit) does with my code. So is there any possibility for me to know ...
11
votes
2answers
1k views

How will the new development of Java influence its interoperability with languages like Scala and Clojure?

As far as I understand, both Scala and Clojure have been designed as new languages that depend on the JVM, and easily integrate with Java code, in the sense that they allow to use Java classes ...
0
votes
1answer
194 views

The idea of functionN in Scala / Functionaljava

From brain driven development It turns out, that every Function you’ll ever define in Scala, will become an instance of an Implementation which will feature a certain Function Trait. ...
22
votes
6answers
2k 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 ...
7
votes
1answer
1k views

What's the problem with Scala's XML literals?

In this post, Martin (the language's head honcho) writes: [XML literals] Seemed a great idea at the time, now it sticks out like a sore thumb. I believe with the new string interpolation ...
9
votes
3answers
4k 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 ...
7
votes
2answers
1k views

Decision for Unchecked Exceptions in Scala

As a java programmer, I have always been critical of Unchecked Exceptions. Mostly programmers use it as an en-route to coding easiness only to create trouble later. Also the programs (though untidy) ...
3
votes
2answers
577 views

null values vs “empty” singleton for optional fields

First of all I'm developing a parser for an XML-based format for 3D graphics called XGL. But this question can be applied to any situation when you have fields in your class that are optional i.e. the ...
5
votes
1answer
382 views

Why do generics in Scala have erased types, and are not reifiable?

Why do generics in Scala have erased types, and are not reifiable? Is it due to lack of support from the JVM or for compatibility with Java libraries? What are the advantages in general of having ...
6
votes
5answers
2k views

What is a good use case for scala? [closed]

In a current project we have setup the build so that we could mix Java and Scala. I would like to use more Scala in our code base to make the code more readable and concise. In the process also learn ...
2
votes
1answer
3k views

Play 2 with Scala or Java? [closed]

I want to develop a big personal project using Play 2 Framework. I am expert with Java language but it seems, with the few articles I read that Play 2 works perfectly and especially with Scala. I've ...
6
votes
3answers
507 views

Functional Methods on Collections

I'm learning Scala and am a little bewildered by all the methods (higher-order functions) available on the collections. Which ones produce more results than the original collection, which ones ...
5
votes
1answer
531 views

Can Scala be considered a functional superset of Java?

Apart from the differences in syntax, can Scala be considered a superset of Java that adds the functional paradigm to the object-oriented paradigm? Or are there any major features in Java for which ...
2
votes
2answers
752 views

What's the best practice for async APIs that return futures on Scala?

I have started a project to write an async PostgreSQL driver on Scala and to be async, I need to accept callbacks and use futures, but then accepting a callback and a future makes the code cumbersome ...