Skip to main content

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.

Filter by
Sorted by
Tagged with
23 votes
2 answers
15k views

Scala does not have break or continue, so some loop behavior takes a bit more of thinking. Ending a loop early requires tail recursion, exceptions, or scala.util.control.Breaks (which uses exceptions)...
Paul Draper's user avatar
  • 6,088
1 vote
1 answer
826 views

I heard a friend say: The first real use of Chris Okasaki's book was in Clojure's data structures I heard another friend say: No, they influenced the design of Scala in quite a subtle way. My ...
hawkeye's user avatar
  • 4,849
2 votes
2 answers
2k views

As I did understand, and as it's described here, ad-hoc polymorphism is limited to compile-time dispatch. That is, if we have a function that expects an argument that belongs to a typeclass, we must ...
Display Name's user avatar
0 votes
0 answers
1k views

Currently working on a server-side front-end Scala Play app that does a lot of grabbing of HTML snippets and JSON from many other web apps before piecing everything together and sending it in a ...
lloydmeta's user avatar
  • 101
0 votes
0 answers
81 views

Let us have case class Money(amount: BigDecimal, currency: Currency) case class Currency(code: String, alpha3: String) Money is a value object and Currency is an entity. When transforming Money to ...
Denis Mikhaylov's user avatar
4 votes
3 answers
4k views

I'm an experienced software engineer, and have experience in a range of languages from PHP, Ruby, C#, Java - the last few years I've primarily worked in Java. I'm now learning Scala, and it's my ...
Richter's user avatar
  • 141
41 votes
12 answers
9k views

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 ...
pathikrit's user avatar
  • 560
12 votes
3 answers
5k views

Just ran across this term here: http://www.codemesh.io/codemesh2014/viktor-klang "We'll demonstrate the Flow API—a lifted representation—as well as a pluggable way of transforming the lifted ...
Den's user avatar
  • 4,887
3 votes
0 answers
1k views

I am learning ZeroMQ and came across the Majordomo Protocol. I am wondering if I'm understanding this correctly, is the use case the same as.. for example.. the Microsoft Azure AppFabric service? ...
Will I Am's user avatar
  • 235
3 votes
3 answers
476 views

In Object Oriented Programming, we're taught to think in terms of Polymorphism (the idea that the implementation is decoupled from the interface - and that it makes sense to think of the interface ...
hawkeye's user avatar
  • 4,849
1 vote
1 answer
788 views

I am working on a Scala project and I want to include some sample data somewhere in the project. Specifically, my Scala project includes code that performs various natural language processing tasks ...
user1893354's user avatar
1 vote
2 answers
217 views

Why do we have the distinction between statements and expressions in most programming languages? For example, in Java, assuming f and g return ints, this still won't compile because it's a statement ...
cdmckay's user avatar
  • 119
15 votes
1 answer
3k views

I came across the NoStackTrace mixin for Exceptions in scala. Is it good practice to use it, or should it be considered "internal" to scala and left alone?
Daenyth's user avatar
  • 8,167
2 votes
2 answers
611 views

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 ...
GlenPeterson's user avatar
5 votes
1 answer
160 views

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. M ...
Isvara's user avatar
  • 630
5 votes
5 answers
3k views

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 ...
ford prefect's user avatar
8 votes
1 answer
3k views

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 ...
2rs2ts's user avatar
  • 515
2 votes
2 answers
678 views

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 ...
MaatDeamon's user avatar
3 votes
1 answer
457 views

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 ...
Paul Draper's user avatar
  • 6,088
9 votes
3 answers
1k views

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 ...
jcora's user avatar
  • 1,491
-1 votes
1 answer
248 views

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 ...
Cui Pengfei 崔鹏飞's user avatar
0 votes
1 answer
403 views

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 ...
Preslav Rachev's user avatar
1 vote
1 answer
402 views

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 ...
Kevin Meredith's user avatar
6 votes
3 answers
2k views

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 ...
Keith Mattix's user avatar
1 vote
4 answers
4k views

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 ...
valenterry's user avatar
  • 2,429
20 votes
2 answers
20k views

(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 ...
Aviv Cohn's user avatar
  • 21.6k
12 votes
1 answer
8k views

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 ...
kurofune's user avatar
  • 290
12 votes
2 answers
5k views

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 ...
user avatar
18 votes
4 answers
3k views

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 ...
Luciano's user avatar
  • 564
0 votes
1 answer
159 views

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 ...
finsbury's user avatar
  • 103
20 votes
1 answer
14k views

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 java.util.function.Function[Int,...
GlenPeterson's user avatar
6 votes
5 answers
2k views

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 ...
jcora's user avatar
  • 1,491
3 votes
1 answer
6k views

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 ...
Kevin Meredith's user avatar
3 votes
1 answer
167 views

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 ...
user116948's user avatar
9 votes
2 answers
6k views

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 ...
jcm's user avatar
  • 229
0 votes
1 answer
479 views

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 ...
user116948's user avatar
2 votes
6 answers
687 views

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 ...
Low Kian Seong's user avatar
1 vote
2 answers
2k views

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, ...
ankit's user avatar
  • 860
11 votes
4 answers
11k views

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 ...
user3047512's user avatar
3 votes
1 answer
2k views

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 ...
hawkeye's user avatar
  • 4,849
9 votes
2 answers
4k views

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, ...
Mark Canlas's user avatar
  • 4,014
15 votes
1 answer
5k views

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 common operation. Why should the ...
DPM's user avatar
  • 1,723
5 votes
2 answers
3k views

Is there a representation for modern programming constructs that are becoming common in modern OOP/hybrid languages like mixins/traits/categories/partial classes ?
Amogh Talpallikar's user avatar
5 votes
1 answer
493 views

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 ...
ShankarG's user avatar
  • 161
68 votes
5 answers
28k views

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 ...
JasonG's user avatar
  • 1,139
7 votes
2 answers
6k views

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 (...
user34903's user avatar
3 votes
3 answers
2k views

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 ...
Adam Arold's user avatar
  • 1,190
2 votes
4 answers
340 views

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 ...
deamon's user avatar
  • 886
4 votes
4 answers
491 views

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 ...
Amir Karimi's user avatar
  • 1,232
15 votes
2 answers
7k views

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 ...
fnl's user avatar
  • 261