jQuery in Action, 2nd edition*
The moose likes Scala and the fly likes Scala in the wild Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala in the wild" Watch "Scala in the wild" New topic
Author

Scala in the wild

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Twitter is using scala in some of its backend infrastructure.
I've been programming in Scala seriously for about a year and a half now and it's positively ruined me for plain Java.


Regards,

Pho
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

It's interesting to see a Ruby guy loving on Scala. It seems he hates Java but recognizes that the JVM is powerful. He also recognizes that dynamic languages (which includes Groovy and JRuby) are slower. That leaves Scala as just about the only decent option.


A good workman is known by his tools.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Marc Peabody:That leaves Scala as just about the only decent option.

I'm working on a clean slate project, considering anything. Python looks interesting, but it lacks the JIT optimizations that we've had with the JVM for years.

I still haven't figured out how to use Scala, but its use of the JVM is a big winner
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

@Pat,

You might want to know that Guido van Rossum (the inventor of python) hates Scala.

http://neopythonic.blogspot.com/2008/11/scala.html
[ December 03, 2008: Message edited by: Pho Tek ]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

@Pho, great link. Very much worth the time to read it.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
The complexity of the type system is the number one complaint I've read about Scala. It usually comes from people who haven't spent a lot of time writing Scala code. This isn't to suggest that only those that can read/write Scala "get it", instead I believe that for 95% of the common use cases, the type system isn't very complex at all, in fact its a lot like the Java type system with more features. And for that last 5% when you actually need do delve into the hairy edge, the type system is robust enough to be able to handle it. I do concede however that this is a PR issue for Scala (if languages themselves can have PR issues)


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Garrett Rowe:
I do concede however that this is a PR issue for Scala (if languages themselves can have PR issues)

Languages can certainly have PR issues. One of the more popular topics in the Scala user list was just this.

I've always seen Groovy presented as "Look at these cool features that make your life easier."
Much of what I've seen about Scala stops a little short at "Look at these cool things you can do with this great language."

Playing around with the language can be fun for academics and hobbyists, but people aren't going to jump on board until they can see how it is going to make programming easier.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
An unexpected place I've encountered Scala was as the implementation language for one of the code samples for JAX-RS (the new Java standard for RESTful web services). It demonstrates generating images of the Mandelbrot function; here's the source for the curious.


Ping & DNS - my free Android networking tools app
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
I agree, the interesting thing is that almost everything that Groovy touts as a "make your life easier" feature, can be done just as easily in Scala.* There are Scala analogues to all the usual cool Groovy collections methods, Scala has closures, and Scala relies less on reflection for most things than Groovy does so it may be a little faster. The one advantage (or disadvantage depending on your perspective) that Scala has over Groovy is its type system. I'm not sure why Groovy has a marketing advantage over Scala, it may be that

*That does not include the meta-programming stuff that Groovy can do like the MarkupBuilder. There is definitely no Scala analogue for that.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Garrett Rowe:
I'm not sure why Groovy has a marketing advantage over Scala, it may be that

The fact that Groovy lets you choose static or dynamic is pretty cool. I do think that what sells most folks on Groovy are all the nice collection iteration methods and such - basically all things that Scala has too.

I believe many companies who are willing to use cutting edge technologies often send their employees to events like the No Fluff Just Stuff conference. The session speakers get everyone all excited about cool new things. In the past few years Scott Davis has been a tremendous evangelist for Groovy. I really haven't seen or heard of anyone in the Scala community like this yet.

In Columbus's No Fluff this past year, there were multiple sessions about Groovy. Only one session even mentioned Scala: Stu Halloway's "Java.next" showing a few of the neato things you can do in each of Clojure, JRuby, Groovy, and Scala. Here's his blog post on the topic.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Nice blog post. Definitely showed how similar tasks can be accomplished in all the "Java.next" languages.


The fact that Groovy lets you choose static or dynamic is pretty cool.


That sours the deal for me. I'm not a big fan of duck typing. Probably because I was weaned on Java and it's static type system, I'm wired to think in types and transformations from types to other types. I didn't really take to Ruby during the 2 weeks I tried to learn it either (maybe I didn't give it enough time).

I don't like pickles either for what it's worth. They can spoil an otherwise perfecly good cheeseburger.
James Iry
Greenhorn

Joined: Dec 20, 2008
Posts: 3
Originally posted by Marc Peabody:

The fact that Groovy lets you choose static or dynamic is pretty cool. I do Here's his blog post on the topic.


Groovy does not let you choose between static or dynamic typing. Groovy has a very few static semantic constraint checks, but it's pretty much a dynamically typed language. When you add type annotations in Groovy what you get is an automatic runtime check that a value has a certain runtime type. That's different from a static type system that proves a value will always have a certain type. That's not to knock Groovy's choice in this matter, it's just to point out the difference. Here's an example.

I create a function that promises an int but returns a String.

groovy:000> def int foo() { return "hello";}
===> true

Groovy accepts it no problem

But then I try to run it and...

groovy:000> foo()
ERROR org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'hello' with class 'java.lang.String' to class 'java.lang.Integer'
at groovysh_evaluate.foo (groovysh_evaluate:2)
at groovysh_evaluate.run (groovysh_evaluate:2)

Now I get the error

Here's the equivalent in Scala. It complains at definition time

scala> def foo : Int = "hello"
<console>:4: error: type mismatch;
found : java.lang.String("hello")
required: Int
def foo : Int = "hello"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Scala in the wild