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
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,344
21
votes
8 answers

Is Scala ready for prime time?

Now that I've done a few trivial things with Scala (which I love for "hello world" and contrived applications!) I am left wondering.. part about maturity of the tools to support development, and part about general applicability. Are the toolsets…
jayraynet
  • 1,190
15
votes
1 answer

Which Scala open source projects should I study to learn best coding practices

What open source projects would you recommend for people to study to learn how the pros write Scala? Some of the attributes that I'm looking for - though they don't all have to be present in every exemplary project: Idiomatic use of the language…
14
votes
2 answers

Scala infix notation

Is it possible to call a method using infix notation? For example, in Haskell, I could write the following function: x `isAFactorOf` y = x % y == 0 and then use it like: if 2 `isAFactorOf` 10 ... Which in some cases allows for very readable code.…
12
votes
2 answers

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 far, all I understand is that I should use…
user125090
9
votes
4 answers

What is a good use case for scala?

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 the language by handing over real features. So…
Usman Ismail
  • 314
  • 2
  • 9
8
votes
6 answers

Built in Scala library slow?

I found this question and accepted answer on StackOverflow. It's related to the slow JSON parser in the standard Scala library. The consensus as it were, is that the build-in JSON library is slow, and, in the words of DMC: "it's like that, and…
Jack
  • 507
7
votes
3 answers

Arguments in support of organizational transition to Scala development

I work in an organization that does extensive Java development. Our group is small with a short-lived project, agile development charter. We will leverage existing QA resources of other groups, and potentially contribute code to customers and…
6
votes
4 answers

Do resumable exceptions make any sense?

Following up my previous question I wonder if resumable exceptions make any sense. It looks like nobody uses them in Java. Don't they use resumable exceptions because of Java limitations or just because they don't really need them? Suppose, I want…
Misha
  • 169
6
votes
2 answers

When to use Future[T] vs. Future[Try[T]] when the call might fail

I am slightly confused when to use which because futures are allowed to fail. If futures are allowed to fail, then to me, that sounds like a Try[] in itself. And if the Try[] is wrapped inside a Future, then what is the difference with a regular…
user1555300
  • 185
  • 1
  • 7
5
votes
2 answers

Scala: From concept to working

Second attempt to ask my question more concisely. I want to say I am a Scala fan, or at least I want to be. I've resigned myself to learning one of these functional languages [Scala, Haskell, Erlang]. I've dabbled in all of them, far and away I…
M15K
  • 203
  • 1
  • 6
5
votes
2 answers

What's the rationale behind the ordering of Scala's value/variable declaration when including a type identifier?

I'm trying to wrap my head around Scala, and one thing that keeps throwing me is the ordering of a variable/value declaration when specifying the type. val a = 0 makes perfect sense. This looks pretty much like any other language. val a: Int =…
3
votes
1 answer

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 as span is used inline and has only one parameter…
3
votes
1 answer

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 is done and if I can use the same mechanism to…
Codism
  • 1,213
2
votes
1 answer

Extends for feature (aka mix-in) in Scala is bad practice, isn't it?

In Scala, sometimes class extends a trait to provide some methods to extending class inside. ScalaTest import org.scalatest._ class ExampleSpec extends FlatSpec with Matchers { ... Matchers trait provides useful method like startWith, endWith or…
1
2