views:

551

answers:

6

Hi, I'm impressed with twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java ?

EDIT: And, do you think google's Noop, Fan or Scala can take the leadership from Java in the near future, which one have chance in your opinion ?

Cheers,

+11  A: 

Don't forget that you can use it alongside Java. i.e. you can make use of compiled .classes and .jars within a Scala-scripted environment.

So you may want to encode the lower-levels of your solution in Java and then wrap these in Scala to provide a more flexible and agile solution (in terms of rewriting business logic at a higher level).

Something to consider is who else is going to look after this and maintain it. For all of Scala's hype, relatively few people can code in it, and you may have to hire people in the future to look after it. Looking for Scala people will mean you're looking in a much smaller pool of candidates (some may want to learn Scala on the job, but there's still a start-up cost)

Brian Agnew
perfect point of view. Thank you very much
sirmak
+2  A: 

A particular issue with Scala is that as a scalable language, it has levels of features of varying degrees of accessibility to the average developer. Using it at as a scripting language for the JVM is one thing, developing a domain-specific language using functional programming is another.

ewg
+4  A: 

Don' forget that it's a relatively small piece of Twitter, notably the message queues, which are written in Scala. From what I understand, the front-end is still Ruby-on-Rails.

That said, I migrated to scala under a year ago: I haven't looked back. Furthermore:

  • there is a large pool of graduates who are very interested in coming to work in a scala shop
  • the fact that scala is built to run on a JVM means that Java developers get a head-start in the language (if you're interested I could expand on why this is so).
oxbow_lakes
"there is a large pool of graduates who are very interested in coming to work in a scala shop"Reference?
Derek Mahar
@Derek - I have first-hand evidence that this is the case; however, it's not quite made it into a peer-reviewed journal. Yet.
oxbow_lakes
+5  A: 

Here are the pros and cons of Scala relative to Java IMHO:

Pros:

  • Much more concise syntax for idioms common in modern Java code
  • Closures
  • More powerful type system including mixins
  • Pattern matching
  • Great REPL, 2.8 will even have tab-completion

In summary: You get a lot more functionality with a lot less code than Java

Cons:

  • IDE support is still of alpha or beta quality, although IDEA has the best support currently
  • The standard library is not immune to changes with each new version (2.8 will have backwards incompatible changes)
  • The standard library had significant bugs at least as recently as a year ago (when I found one in the JSON support)

I think Scala will be ready for major production use in 6-8 months, but I wouldn't bet my project on it today.

sanity
thank you for this comprehensive review
sirmak
Personally, I think speaking of "significant bugs" is inappropriate. It wasn't that bad 1 year ago, and it certainly isn't bad right now. It's not like Java doesn't have a fair share of outstanding tickets (some dating years).
Daniel
Daniel, I found a crash while parsing JSON that would have been picked up by even the most rudimentary of unit tests. I do consider that a significant bug in a standard library.
sanity
+2  A: 

If you are considering using Java and Scala in a single project environment, I would suggest using Maven as a project dependency system. Here is the code I use to generate my scala projects:

mvn archetype:generate -DarchetypeCatalog=http://scala-tools.org/

Here is some usage information for using maven with Scala. If you use maven as the compiler, you can have both java and Scala source files in the same package with no extra configuration. It just works.

Here is a talk hosted by LinkedIn. Its a Panel with Scala, Twitter, and Scala lift web framework (which I use). If you are still deciding whether to use Scala id suggest watching it.

+2  A: 

One advantage of Scala is that you can build it alongside Java in the same project. Both Maven (see luigi-prog's comment) and simple build tool have fairly simple hooks that will build everything in one go.

Another way is to take existing unit tests, switch the implementation, see the difference.

Daniel Spiewak had a few nice entries on the gotchas of Java-Scala interop.

I have been using Scala in the workplace for the past year, and I'd say it's about a 3-month learning curve to become fairly proficient. This is with a fairly small group of typical Java people. There's a lot of volatility yet in terms of conventions and standards, so expect to do some revision on any project every few months.

I don't think you can search for 'Scala programmers' just yet. But you can find lots of Java programmers who are interested in learning Scala.

If I were to guess, Scala and Clojure might be the front runners for 'supplanting' Java. I wouldn't expect a major shift until 2012 at the earliest. Scala probably leads in momentum - there are several books in multiple languages now.

Tristan Juricek
I wanted to add that with Scala you'll likely want an easy 'cross-compilation' system to build your code with the current "production" version + new versions. sbt (simple build tool) makes it easy.
Tristan Juricek
thank you. I want to ask does scala improves productivity ? And does it cause any kind of problem in projects ?
sirmak
"Improves productivity" is a very relative to the programmers doing the work. I think it's a very involved language, and, somewhat unstable, so, if people aren't interested in spending time simply exploring new ideas, you'll probably see a lot of time wasted to "how I make things work for me all the time" sorts of questions. In the hands of good developers, you'll be amazed at how fast you can start to put together systems, and the overall SLOC reduction. It's all about people willing to explore the possibilities.
Tristan Juricek
great post, thank you very much Tristan.
sirmak