aspose file tools*
The moose likes Scala and the fly likes What does Scala offer (besides concurrency)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "What does Scala offer (besides concurrency)?" Watch "What does Scala offer (besides concurrency)?" New topic
Author

What does Scala offer (besides concurrency)?

Dan King
Ranch Hand

Joined: Mar 18, 2009
Posts: 84
I'm trying to determine whether it makes sense for me to invest the time and effort needed to learn Scala -- to that end, I want to better understand what does Scala offer. One of the biggest selling points I've read about is it's inherent concurrency features but beyond concurrency, what else does it offer? Also what domains is Scala best suited for? For example, can one use Scala to implement a ticker plant and have the same if not better results than a combination of C++ and Java?

Thanks.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Things I like about scala:
  • Fun
  • Rich type system
  • Language support for functions as first class values
  • Type inference
  • Implicit conversions
  • Runs on the JVM
  • Performance
  • Easy interface with java


  • There's a lot of other stuff too, but those are my top points. The Actor concurrency library that you're probably referring to is just that, it's a library. It's an abstraction layer built on top of some low level primitives. Will your pure Scala app be faster than your pure Java app? Probably not, but it won't be much slower and it may be faster to code. If you're writing something for yourself, I say do it with tools you enjoy using. I think that's why a lot of people choose Scala.


    Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14435
        
      23

    After working with Scala for a while, I feel that it's much more elegant and concise than Java. When programming in Java again I notice how verbose and old-fashioned Java is.

    For example, you don't need to write getters and setters in Scala. Writing a simple bean-like class can be done in a single line, for example:

    Compare this to the Java version:

    And if you need equals(), hashCode() and toString() methods, you can just make it a case class, and these will be generated for free:

    In Java, you'd have to write them yourself, and be careful, because it's easy to make a mistake in implementing those methods.

    Type inference also helps a lot to keep the code simple and more readable. Another feature that I like a lot are traits, which give you a lot more flexibility in structuring your program. Traits can be used as mixins, which can be very useful for adding functionality to classes.

    Also, Scala doesn't have primitive types in the language. For example, Int is a class and you can call methods on integers as if they are objects. Under the covers, Scala will use primitive ints, so that using Int is just as efficient as using a primitive int in Java. Scala makes your life a lot easier because you don't have to be constantly aware of primitive types and wrapper classes.

    And there's ofcourse a lot more. Scala just feels like a much more modern and more powerful language than Java.

    What domains Scala is best suited for: it's a general-purpose programming language that runs on the JVM, and has similar performance to Java. You can use it whereever you have a JVM, from server-side software to mobile devices (there are for example ways to program your Android phone in Scala instead of Java). It interoperates almost seamlessly with Java, so you can use any Java library directly from Scala. There are also a number of web application frameworks, Lift is the most well-known at the moment.

    Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: What does Scala offer (besides concurrency)?