Niche for Scala

At last post I mentioned that i’m not using Scala because of academic nature, syntax and so on. BTW, i’ve different used programming languages, sometimes with worst syntax. I spent much time on Perl. And also i’ve used Q programing language. You know, Scala have much better syntax :) I only don’t understand why they are drop standard java syntax for standard cases? Why

for(i <- mylist ){
  print(i)
}

is better than standard:

for (i: mylist) {
  print(i)
}

, etc. I see only one reason: to be different. What for?

But actually it doesn’t matter. I’ve used Perl and Q only because they have their niche, where they’re works best (ok, perl lost it now, but you know, when I used it, 10 years ago it has it). But I don’t understand niche of Scala. What is it for? If I want to develop fast code – i will choose Java. If I’m looking for syntax sugar and easy development – Groovy. Want functional code – choose Clojure. It’s just my current vision.

I definitely will try Scale one more time. Just because i see that many interesting project are using it, GridGain for example. But first I need to understand what project better fits for Scala. Can someone help me with it?

Share this post: Tweet about this on TwitterShare on RedditShare on FacebookShare on LinkedInShare on TumblrShare on StumbleUponShare on Google+Email this to someone
 

Igor Artamonov

Professional software developer since 2001, have been writing code since 1995. Data processing for Cloud, Ethereum & Blockchain

 
  • I would consider using Scala instead of Java in almost every case. It gives you powerful syntax (with functional style and a lot of sugar too), great libraries and static typing for only small runtime overhead. Valid excuse not to use Scala is where you cannot live without an extensive tooling and/or frameworks that rely on Java. In that case however it’s better to check, if the problems could not be solved in a simpler way with Scala.

  • steve

    But what will you do if you want to develop fast, want to have “syntax sugar”, easy development AND functional code all at one?

    Right, you choose Scala.

    Regarding your complain about the for syntax.

    a) “:” is used for type annotations. “i: mylist” would make it look like i was of type mylist.

    b) If you look at the big picture (were Scala’s “for” hasn’t much in common with Java’s “foreach” syntax) “<-" is much more obvious than ":".

    c) Java syntax is OK for what Java can do. But it just doesn't scale. Look at C#, look at LINQ, look at Java's proposed closure syntax, look at Generics. Most programming language designs today have switched from "Type" "identifier" to "identifier": "Type", because the first one doesn't scale and isn't readable when type inference comes into play.

    Scala is basically everything Java should have been in the first place and much much more.

    – No distinction between primitives/objects. Same clean syntax for everything.

    – Sane Generics. Allows more things which are safe to do and disallows things which are proven to fail, instead of Java's "Let's just fail at runtime".

    – Mixins. If you need composition, you use it. No weird "Let's implement that interface the tenth time".

    – No statics. Scala's approach (having companion objects) is much easier to understand for beginners, because "static" and non-static members are cleanly seperated.

    – Properties. Code doesn't break like in Java, if you would switch from field access to method calls.

    – XML. Everyone hates working with XML in programming languages. Scala makes it bearable to use it.

  • Torsten

    It’s easy to say why I prefer Scala. Scala has the features I expected form the next Java now.

  • Dave

    What makes you think it needs a niche? It’s a GP language. Use it for anything.

  • Igor Artamonov

    @Dave Java, Groovy, Clojure, Perl, C, and even PHP are GP languages. But for every specific project we choose best tool for this project, isn’t it? I don’t think that there is silver bullet that best fits for every project.

  • Igor Artamonov
  • Pingback: Tweets that mention Niche for Scala « Igor Artamonov -- Topsy.com()

  • florin

    http://fantom.org

    It fixes 99% of java complaints. It is both oo and functional. Syntax just fine.

    But of course, it lacks the sophistication of Scala, the mind numbing type system (per J. Gosling), the myriad ways of doing one thing, etc. therefore it is demeaning to the elite: one cannot awe an audience with cleverness and obfuscation.

    Java for the the slow minds.
    Python for those with a life.
    Ruby for the rebel crowd.
    PHP for the amateurs.
    Closure for the excentrics.
    Pearl for the old fashioned.
    Go for the Google groupie.
    Objective-C for the submissive.
    C# for the career path.
    JavaScript for the hip & cool.
    Scala for the smarter than thou.

    http://fantom.org – It just works, therefore nothing to write home about, unless you want to get things done.

  • D. De Maeyer

    The big advantage of Scala is that it runs on the Java platform and can use standard Java libraries. This creates a big advantage over Perl/Q, it has all the benefits Java has/had and the syntax is more complicated but so much more powerful. I find that when programming Scala you have more time to think about the program than to think about the syntax (as I find is the case writing Java sofware).

  • Why should “for (i: mylist)” be better than “for(i <- mylist)"? They are both in the same league of ugliness and bad readability. Take a look at Python: "for i in mylist:" Could it be more clear?

    Scala is the future because it is so much more powerful and cleaner than Java. There is so much complexity in Java APIs because of the limitations of the language. Since the language itself cannot be extended, developers are using annotations + reflection and kill static typing this way. The limitation to single inheritance cause many ugly workarounds. The Java syntax is bloated – think of the stupid getters and setters and missing named parameters with default values. The latter causes other workaraounds like the builder pattern. Another thing is that Scala makes it much easier to write immutable classes, what is essential for parallel execution.

    Groovy is poor compared to Scala. The language is not so powerful, not (really) statically typed and has a lot of runtime overhead which leads to horrible stack traces.

    So, give Scala another try!

  • If you like GridGain – take a word from us: use Scala for everything… productivity gains are substantial and every time we need to go back to Java – it’s hurting really bad.

    Best,
    Nikita Ivanov.
    GridGain Systems.

  • neo

    Scala has the features I expected form the next Java now.
    good one fan of java