Tagged Questions

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

-2
votes
2answers
48 views

Java 8 vs Scala? Which one to learn? [on hold]

Scala has been promoted with advantages of perfect mix of functional programming and pure OOP and some more features which is difficult to achieve with java like reliable multi-thread programming. I ...
0
votes
0answers
21 views

Which Way Is Suitable to Implement Set collection In Scala [on hold]

I want to implement Set in scala. In order to implement set in scala, there are three ways which are hashset,treeSet and LinkedSet. My question is that which of them is suitable to implement in "worst ...
0
votes
1answer
45 views

in scala type linearization explain first step in algorithm [closed]

I saw this explanation Where first step is: "start building a list of types, the first element is the type we’re linearizing right now," however the result of this is: // start with D1: B ...
7
votes
1answer
333 views

Why does Scala have return but not break and continue

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 ...
1
vote
1answer
119 views

What was the influence of Chris Okasaki's data structures on Scala? [closed]

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. ...
2
votes
2answers
90 views

Is it possible to have Ad-Hoc polymorphism with runtime dispatch?

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 ...
0
votes
0answers
38 views

Controllers passing Request objects to backend logic that forward Request data: Good or Bad?

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 ...
0
votes
0answers
43 views

Is there a pattern for deserialization involving repository access? Or what is wrong with my design?

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 ...
0
votes
3answers
162 views

Help me to understand 'stateless' software in functional programming

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 ...
35
votes
12answers
4k views

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

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 ...
8
votes
3answers
1k views

What is a “lifted representation”?

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 ...
0
votes
0answers
83 views

ZeroMQ and Majordomo protocol

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? ...
2
votes
3answers
191 views

Is 'design with types first' ultimately the same as 'design with interfaces first'?

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 ...
0
votes
1answer
27 views

Where to put sample data in project structure

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 ...
0
votes
2answers
62 views

Map multiple functions over a single data item [closed]

I'm in the process of learning Scala and I came across a scenario today where I need to map multiple functions over a single piece of data and wondered if there was a formal name for this. It sort of ...
1
vote
2answers
160 views

If there's no problem treating a statement as an expression, why was there a distinction in the first place in some programming languages? [duplicate]

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

Is it good practice to use NoStackTrace in scala?

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?
2
votes
2answers
176 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 ...
5
votes
1answer
63 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
161 views

Many Arguments in Case Classes [closed]

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
105 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
118 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 ...
3
votes
1answer
78 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
981 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
77 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
300 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
1answer
171 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
214 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
289 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
299 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 ...
6
votes
1answer
1k 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
134 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
69 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 ...
5
votes
1answer
320 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 ...
1
vote
1answer
2k 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
111 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
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
170 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 ...
1
vote
2answers
224 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, ...
7
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
513 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
871 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
689 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
574 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
450 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
340 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 ...