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.
2
votes
2answers
138 views
Java: method takes varargs of unrelated types
I have a Java factory method with a varargs array of Objects at the end. The array can contain any combination of Strings and ScaledJpegs. The theory being that an HTML table cell can contain any ...
4
votes
0answers
37 views
Coping with build order requirements in automated builds
I have three Scala packages being built as separate sbt projects in separate repos with a dependency graph like this:
M---->D
^ ^
| |
+--+--+
^
|
S
S is a service. ...
1
vote
5answers
89 views
Many Arguments in Case Classes [on hold]
I have generally read that having many (>4) arguments to a function/constructor is a bad practice.
Is this still considered a bad practice? And is there a non-obvious reason?
In something like a ...
3
votes
1answer
48 views
When to declare @throws with a Scala annotation - abstract parent or concrete implementation?
In this StackOverflow question I asked about the behavior of the @throws annotation in Scala. Now that I understand how it works I want to ask about best practices with using it. Here's a repost of my ...
0
votes
2answers
80 views
SOAP message testing
I am working in Scala/Java.
I'm testing the messaging infrastructure of a part of my system that I did several years ago with CXF and Java. More specifically, I'm re-writing the specification of the ...
2
votes
0answers
46 views
Implementing a generic and covariant Set in Scala [migrated]
I'm struggling with manually implementing a simple purely functional Set that's also generic and covariant on its type parameter:
Set must be a trait, allowing for multiple implementations.
it must ...
3
votes
1answer
61 views
Why is subclassing TraversableOnce not recommended
Reading http://www.scala-lang.org/api/2.11.1/index.html#scala.collection.TraversableOnce:
Directly subclassing TraversableOnce is not recommended - instead, consider declaring an Iterator with a ...
8
votes
3answers
923 views
Is duplicate syntax for defining named functions a bad language design decision?
I am modelling a programming language for fun, and the syntax is heavily influenced by Scala - specifically function definitions.
I have encountered a design problem because my language does not ...
-1
votes
1answer
70 views
What is the session about simplicity that Martin Odersky suggested during the “Scala with style” talk? [closed]
The video of Scala with style is here: http://parleys.com/play/51c1994ae4b0d38b54f4621b/chapter21/about
It's around 41:10 that he suggested another talk.
I can not hear the name of speaker or the ...
1
vote
1answer
287 views
Should we push for more JavaScript on the JVM, alongside Java and Scala? Or, if not, why?
With JavaScript becoming one of the most widely used languages around, I began asking myself why people do not find ways to use it extensively on the JVM. As a programmer who spends half day writing ...
1
vote
0answers
141 views
Why does my C++ (OpenMP) matrix operations code start incurring more cache misses running in parallel compared to Scala? [closed]
I have written code using C++ (OpenMP for parallelizing loops) which does lots of matrix operations. A single instance of the code runs very fast and completes in 0.2 seconds. For the same processing, ...
0
votes
1answer
118 views
Type Safety of Spray.io
Yesterday I read a tweet disparaging Jersey with JAX-RS due to run-time errors. Spray.io was mentioned in the tweet:
Not even 5 minutes using Jersey / JAX-RS and already a runtime error
due to a ...
5
votes
3answers
188 views
Decreasing vars in Scala programs
I have been studying scala for the past week or so and the ideologies associated with it and functional programming in general. As expected, the leap from imperative to functional programming is not ...
1
vote
4answers
250 views
Alternatives to null values and option-like types
Related to this question i want to know if there is a concise way to eleminate null values out of code in general or if there is not.
E.g. imagine a class that represents a user with birthday as ...
2
votes
2answers
196 views
How do Traits in Scala avoid the “diamond error”?
(Note: I used 'error' instead of 'problem' in the title for obvious reasons.. ;) ).
I did some basic reading on Traits in Scala. They're similar to Interfaces in Java or C#, but they do allow for ...
7
votes
1answer
508 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 ...
0
votes
2answers
93 views
Parameterless & Empty-Paren methods in Scala
I'm learning Scala at the moment via Odersky's Programming Scala (2nd). I'm upto chapter 10 where he starts introducing parameterless and empty-paren methods. I just can't get my head around it.
So ...
13
votes
4answers
2k views
Does functional programming add complexity in code? [closed]
For the entire past year I've been written Scala code (coming from a Java background). I really liked how you could create simpler and cleaner code, with vals, case classes, map/filter/lambda ...
0
votes
1answer
63 views
Preferred Scala code style for several embedded brace sets
I was wondering the correct way to format a situation such as this, where I have a def, a foreach and an if clause all nested, requiring braces.
Currently I find it hard to read, and there is no ...
4
votes
1answer
207 views
Passing a Scala function to a Java 8 method
The following Scala code works and can be passed to a Java method expecting a function. Is there a cleaner way to do this? Here's my first pass:
val plusOne = new ...
5
votes
5answers
1k views
What negative consequences can arise from this language design rule?
Clarification: the rule is meant to prevent accessing variables that are not declared yet.
Clarification 2: the rule mandates that the compiler follows calls to functions which are defined in the ...
2
votes
1answer
1k views
JSON Library - Jackson or Play Framework? [closed]
Working on a Java and Scala code-base, there's a debate about whether to use Java's Jackson JSON or the Play Framework's JSON Library.
After reading the Play JSON Docs, as well as Chapter 9 (JSON) of ...
3
votes
1answer
99 views
Understanding special Scala syntax
I can understand this:
List("one word", "another word") unzip (_ span (_ != ' '))
But don't get what's happening here below in the span. span takes a predicate and I think the braces can be omitted ...
3
votes
2answers
725 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
120 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
474 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 ...
1
vote
2answers
176 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
3answers
2k views
Why Big Data Needs To Be Functional?
I started working on a new project lately related to Big Data for my internship.
My managers recommended to start learning functional programming (They highly recommended Scala).
I had a humbled ...
0
votes
1answer
395 views
Why the Scala fascination with flatmap? (This doesn't seem to be the same for mapcat in the Clojure world) [closed]
In the Scala community - there is an apparent fascination with the FlatMap function.
Now I understand that FlatMap is significant because it is used for the bind part of a Monad. (and that the ...
6
votes
2answers
680 views
What is the difference between self-types and trait inheritance in Scala?
When Googled, many responses for this topic come up. However, I don't feel like any of them do a good job of illustrating the difference between these two features. So I'd like to try one more time, ...
-6
votes
3answers
625 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 ...
6
votes
1answer
451 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 ...
2
votes
1answer
362 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 ?
4
votes
1answer
311 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
225 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 ...
16
votes
3answers
4k views
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 ...
2
votes
3answers
182 views
How to name nested function?
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
591 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
264 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 ...
4
votes
4answers
412 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 ...
7
votes
1answer
711 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 ...
11
votes
4answers
3k 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
2answers
747 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 ...
2
votes
1answer
559 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
726 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",
...
0
votes
1answer
162 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 ...
10
votes
2answers
930 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
...
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 ...
6
votes
4answers
821 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 ...
6
votes
2answers
895 views
Node.JS or Scala for mobile and web apps
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 ...