views:

769

answers:

4

It is my opinion that every language was created for a specific purpose. What was Scala created for and what problems does it best solve?

+6  A: 

One of the things mentioned in talks by Martin Odersky on Scala is it being a language which scales well to tackle various problems. He wasn't talking about scaling in the sense of performance but in the sense that the language itself can seem to be expanded via libraries. So that:

val lock = new ReentrantReadWriteLock
lock withReadLock {
   //do stuff
}

Looks like there is some special syntactic sugar for dealing with j.u.c locks. But this is not the case, it's just using the scala language in such a way as it appears to be. The code is more readable, isn't it?

In particular the various parsing rules of the scala language make it very easy to create libraries which look like a domain-specific language (or DSL). Look at scala-test for example:

describe("MyCoolClass") { 
  it("should do cool stuff") {
     val c = new MyCoolClass
     c.prop should be ("cool")
  }
}

(There are lots more examples of this - I found out this one yesterday). There is much talk about which new features are going in the Java language in JDK7 (project coin). Many of these features are special syntactic sugar to deal with some specific issue. Scala has been designed with some simple rules that mean new keywords for every little annoyance are not needed.

oxbow_lakes
This seems like an aspect of Greenspun's tenth rule.
Svante
+3  A: 

One more of the original design goals was of course to create a language which runs on the Java Virtual Machine and is fully interoperable with Java classes. This has (at least) two advantages:

  • you can take advantage of the ubiquity, stability, features and reputation of the JVM. (think management extensions, JIT compilation, advanced Garbage Collection etc)
  • you can still use all your favourite Java libraries, both 3rd party and your own. If this wasn't the case, it would be a significant obstacle to using Scala commercially in many cases (mine for example).
oxbow_lakes
All true, but also true of many other JVM-based languages. What distinuishes Scala from the others? Superficially, its headline features are already available in other JVM languages.
skaffman
He didn't ask what distinguishes Scala from other JVM languages
oxbow_lakes
I know, but I am :)
skaffman
Haha - you know more about Scala than I do, skaffman - feel free to edit my answer!
oxbow_lakes
+1  A: 

Since it's functional and uses actors (as I understand it, please comment if I've got this wrong) it makes it very easy to scale nearly anything up to any number of CPUs.

That said, I see Scala as kind of a test bed for new language features. Throw in the kitchen sink and see what happens.

My personal opinion is that for any apps involving a team of more than 3 people you are more productive with a language with Very Simple and Restrictive Syntax just because the entire job becomes more how you interact with others as opposed to just coding to make the computer do something.

The more people you add, the more time you are going to spend explaining what ?: means or the difference between | and || as applied to two booleans (In Java, you'll find very few people know).

Bill K
That's why all large software projects are written for the Universal Turing Machine
oxbow_lakes
As I said it is my personal opinion, not very widely held.
Bill K
Bill, what you describe seems to be the basic premise of Java to me.
Svante
Yes, I really appreciate Java, but it's getting way too complex. With the addition of Generics it is now more difficult to create a generic class (which removes one of the biggest advantages--that creating a class is as easy as using one). They are talking about adding more syntax. I'd take some syntax away, remove all variable types but private and probably put hard limits on the size of methods and number of methods per object; but you are right, simplicity is one of the biggest differentiators for Java.
Bill K
Not that there isn't a place for kitchen sink languages! Ruby is really interesting, Scala has some awesome concepts, etc. It's just that I wouldn't want to work in any language but java if I were forced to work with a group that didn't really "Live" programming (which always seems to be the case).
Bill K
Scala may have started as a research project, but it's rapidly becoming a very practical language - something most such projects never even think of achieving.
Marcus Downing
+3  A: 

Another goal of Scala was to bridge the gap between functional and object-oriented languages. It contains many constructs inspired (i.e. copied from!) functional languages. I'm thing of the incredibly powerful pattern-matching, the actor-based concurrency framework and (of course) first- and higher-order functions.

Of course, your question said that there was a specific purpose and I've just given 3 separate reasons; you'll probably have to ask Martin Odersky!

oxbow_lakes