scala

Does this Scala actor block when creating new actor in a handler?

I have the following piece of code: actor { loop { react { case SomeEvent => //I want to submit a piece of work to a queue and then send a response //when that is finished. However, I don't want *this* actor to block val params = "Some args" val f: Future[Any] = myQueue.submitWork( para...

Migrating from Java concurrency to Scala concurrency

I have a fairly standard mechanism in Java for solving the problem: Work items must be scheduled to execute at a particular time Each work item must then wait on a condition becoming true Work items should be cancellable The solution I use is as follows: Have a single-threaded scheduler to schedule my work items Have an ExecutorSe...

Is the lift framework as "easy" as ruby on rails or django?

Just wondering if anyone has experience with the three. I have used read through some RoR and used Django. They seem fairly easy to use. Is lift "easy" like these two are? I know easy is subjective and has no context here. I mean in a very high level and general sense. ...

How to write Tetris in Scala? (code review)

Today's the 25th birthday of Tetris. I believe writing Tetris clone is one of the best ways to familiarize oneself to a new language or a platform. It's not completely trivial and it lends itself well to learning language specific constructs like iterators and closures. I've been hearing about Scala, and finally decided to read some doc...

MapReduce implementation in Scala

I'd like to find out good and robust MapReduce framework, to be utilized from Scala. ...

Batch processing in Scala

I have a number of runnable programs written in Java that I'd like to set into one class that would run those one after another in Scala. So for example I have classes: RunMe with arguments "A", "B", "C" WorkbookLoader with arguments "c:\workbooks\", "c:\sourceFile.bin" and "c:\targetFile.bin" i just need those to call one after anothe...

Handling properties in Scala

I'd like to know what is the most efficient way of handling properties in Scala. I'm tired of having gazillion property files, xml files and other type of configuration files in Java and wonder if there's "best practice" to handle those someway more efficient in Scala? ...

Scala - modifying nested elements in xml

Hi, I'm learning scala, and I'm looking to update a nested node in some xml. I've got something working but i'm wondering if its the most elegant way. I have some xml: val InputXml : Node = <root> <subnode> <version>1</version> </subnode> <contents> <version>1</version> </contents> </root> And i want...

What's the best Scala build system?

I've seen questions about IDE's here -- Which is the best IDE for Scala development? and What is the current state of tooling for Scala?, but I've had mixed experiences with IDEs. Right now, I'm using the Eclipse IDE with the automatic workspace refresh option, and KDE 4's Kate as my text editor. Here are some of the problems I'd like to...

Logging in Scala

What is a good way to do logging in a Scala application? Something that is consistent with the language philosophy, does not clutter the code, and is low-maintenance and unobtrusive. Here's a basic requirement list: simple does not clutter the code. Scala is great for its brevity. I don't want half of my code to be logging statements l...

Scala - replaceAllIn

First off, I'm new to Scala. I'm trying to make a template parser in Scala (similar to Smarty (PHP)). It needs to search through the document, replacing anything inside "{{ }}" tags, with anything provided in the HashMap. I'm currently stuck here: import scala.collection.mutable.HashMap import scala.io.Source class Template(filename:...

Most scalable web stack for high performance Flash/Flex/AIR app?

I am in the planning phase of a new multi-user client/server app using Flash via Flex and AIR. I am trying to decide which web platform/stack is the best suited for this? I have used RoR in the past, but as i understand, RoR is single-threaded, and is therefore not the ideal choice for handling potentially thousands of simultaneous req...

GUI programming in Scala

I'm trying to learn Scala, and I'd like to learn by writing a simple swing app, but I'm unsure what GUI programing looks like in a functional world, and specifically when using Scala. Any pointers, or tutorials, or gotchas when coming from an OO/Java background would be really welcome. ...

Dissimilar Scala book in near future

I've seen quite a few books about Scala, but those are so similar to each other. Wonder what titles (related to Scala) would you like to see that would differ from "main stream"? ...

How to integrate Scala language with Spring Security

I'd like to know how to integrate Scala with Spring Security (i.e. Acegi)? What are best practices and roadblocks while doing the integration ...

How to pass a class object from Scala to Java?

I'm trying to use a Java class library from Scala code. (JGraphT, to be precise.) One of the constructors I need to call is public class SimpleGraph<V, E> extends AbstractBaseGraph<V, E> implements UndirectedGraph<V, E> { public SimpleGraph(Class<? extends E> edgeClass) {...} } To call this from Java, I would say: Undirec...

Scala generics in comparison to C#

I'm just wondering about an implementation detail of sScala generics. In C# one can declare a class as: class Foo<T1>{} class Foo<T1, T2>{} In Scala however the same thing would have to be declared as class Foo0[T1]{} class Foo1[T1, T2]{} Notice how the class name is forced to be changed for multiple generic parameters. Is there ...

Scala actors as single-threaded queues

I'd like to use actors in a program where I'll have some kind of restriction around treating some of the actors as if they were queues. For example, suppose I have some external system to which change events are applied and also some cache of the external system's data. So I have 2 actors: ChangeApplicationActor CacheActor As part of...

Scala - which characters can I omit

In Scala, why can I omit the dot and brakets in T m 0 (instead of T.m(0)): scala> object T { def m(i:Int) = 0 == i } defined module T scala> T m 0 res19: Boolean = true But why can't I omit the brakets in n(0): scala> def n(i:Int) = 0 == i n: (Int)Boolean scala> n 0 <console>:1: error: ';' expected but integer literal found. ...

Can Scala actors process multiple messages simultaneously?

The reply to a recent question of mine indicated that an actor processed its messages one at a time. Is this true? I see nothing that explicitly says that (in Programming in Scala), which contains the following snippet (pp. 593) If [the react method] finds a message that can be handled, [it] will schedule the handling of that message...