scala

Unit testing Scala

Hi! I just recently started learning the Scala language and would like to do it in TDD-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them. I'm using IntelliJ IDEA for Scala development, so it would be nice to be able to run the tests with IDE-support. ...

Is scala.net production ready?

Scala seems to have a .net implementation too. I was wondering if it's a complete implementation with no lose ends or just a showcase thing. It's important because the app we are about to develop should have Windows GUI besides the main implantation on web. Having a language where the core code can be ported between two implantations lo...

Why does Scala have very little enthusiasm about it?

I've noticed over time that Clojure users have nothing but massive enthusiasm for the language. Yet it seems most Scala users don't even really care too much for the language. A few people have told me "It's better than having to use Java.". I'm not sure why Clojure has so much enthusiasm about it yet Scala has hardly any. It ruins any m...

What does it mean to 'hash cons'?

When to use it and why? My question comes from the sentence: "hash cons with some classes and compare their instances with reference equality" ...

How is pattern matching in Scala implemented at bytecode level?

How is pattern matching in Scala implemented at bytecode level? Is it like a series of if (x instanceof Foo) constructs, or something else? What are its performance implications? For example, given the following code (from Scala By Example pages 46-48), how would the equivalent Java code for the eval method look like? abstract class Ex...

Scala XML serialization

Seeing the power of Scala, I wonder if an arbitrary object graph could be serialized and deserialized to/from XML using built-in Scala language features and libraries (e.g. without XMLEncoder, XStream or JAXB). Unfortunately, I haven't found such a solution. What could you advise? ...

Scala lift framework, ajax form that submits multiple values?

I am just getting started with lift and I am now trying to change a normal form to an ajax form but the method processEntryAdd is never called. def addUser(xhtml : Group) : NodeSeq = { var firstName = "" var lastName = "" def processEntryAdd() { Log.info("processEntryAdd: " + firstName + ", " + lastName) } ...

Do Scala libraries follow the same inverted domain convention for naming packages as Java?

I'm looking to write a small Scala library to get a feel for its Actor programming model. In the example code I've come across, some libraries use inverted domain (e.g. org.foo.bar) for packages and some do not (maybe just for brevity). Is it advisable for Scala libraries to use the same package naming conventions as Java? More ge...

Why cannot this.type be used for new instances

I'd like to be able to use this.type to define a method that makes new instances of an immutable case class. Something like this: trait Expression { def left : Expression def right : Expression def new_with_changes(l : Expression, r : Expression) : this.type } case class Derived(left : Expression, right : Expression) { def ne...

Enumerating attached DVD drives in Linux / Java / Scala

In my Scala (runs on top of Java) Application I would like to get a list of all drives that contain DVD media, e.g. something like this: /dev/scd0 Star Trek DS9 DVD1 /dev/scd0 The 4400 DVD1 Not sure if it's possible to get the name of the disc, but the path is the important thing for me anyway. I would prefer a pure Java / Sca...

What are some example use cases for symbol literals in Scala?

The use of symbol literals is not immediately clear from what I've read up on Scala. Would anyone care to share some real world uses? Is there a particular Java idiom being covered by symbol literals? What languages have similar constructs? I'm coming from a Python background and not sure there's anything analogous in that language....

Can I Determine the Set of First Chars Matched by Regex Pattern?

I would like to be able to compute the set of all characters which may be matched as the first character in a string by a given instance of java.util.regex.Pattern. More formally, given the DFA equivalent to a certain regular expression, I want the set of all outgoing transitions from the start state. An example: Pattern p = Pattern.c...

Scala: Is there a way to use PriorityQueue like I would in Java?

I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but I don't want to make it Ordered[A] just for this one purpose. I don't consider the ordering I want to use with respect to the PriorityQueue as the natural ordering of the class. class MyObject (sequence: Int, values: List[String]) ... So, in my ...

What is the current state of tooling for Scala?

Over the past year, I've heard an increasing amount of hype regarding the Scala language. I know that there are several existing projects that have plans to integrate Scala support with IDEs; however, it isn't always clear how good the integration really is. Do they currently support Intellisense as well as Eclipse and Netbeans do for ...

Use Class Variables As Constants In Scala

I'm working to learn Scala--coming from a C++ background. I am trying to write a small class for a task tracking app I'm hacking together to help me to learn how to code Scala. This seems as if it should be simple but for some reason it's eluding me: package com.catenacci.tts class Task(val ID:Int, val Description:String) { val Empt...

Learning Scala or Haskell

I'm considering dipping my toe in the functional programming world, and wondering if it would be better to start with Scala or Haskell. I'm coming at this primarily as a Python programmer. My only real functional programming experience with functional programming is using Scheme in an intro comp-sci class over a decade ago. Some of th...

Creating a jar file from a Scala file

I'm new to Scala and don't know Java. I want to create a jar file out of a simple Scala file. So I have my HelloWorld.scala, generate a HelloWorld.jar. Manifest.mf: Main-Class: HelloWorld In the console I run: fsc HelloWorld.scala jar -cvfm HelloWorld.jar Manifest.mf HelloWorld\$.class HelloWorld.class java -jar HelloWorld.jar =...

Abstract Types / Type Parameters in Scala

I am trying to write some Scala code that needs to do something like: class Test[Type] { def main { SomeFunc classOf[Type] val testVal: Type = new Type() } } and it's failing. I'm obviously not understanding something about Scala generic parameters. Clearly, the misunderstanding is that in C++, templates essen...

functional languages (erlang, f#, haskell, scala)

Hi, 1) Are functional languages suited for web applications development ? 2) Are functional languages suited for business/erp/crm type of applications ? ...

Expressing quantities with units prettily in Scala

I need support for quantities with units. I'd like the type system to enforce unit correctness as much as possible. For example, it shouldn't be possible to combine grams with dollars. I'm going down the path of parameterized types, but this code seems far more repetitious than Scala code I've seen from others. abstract class UnitOfMea...