26

So now Eclipse has offered Xtend and JetBrains is offering Kotlin - both of which seem to be watered down versions of Scala. My question is why? I've played with Scala a bit and it's not that hard. Is this just a reaction to the inherent difficulty of the leap from imperative to functional or is there something else at work here?


EDIT: Apologies. Rereading the question as I originally posted it I can see where it sounds a bit like trolling. The way I phrased the question just seemed to be the best way to ask the question. I have seen blog postings to the effect "Scala is too hard/Scala is too complex" and also "Kotlin is an attempt to do Scala but simpler". I'll leave the phrasing as it was originally but I honestly wasn't trying to troll.

10
  • 20
    It seems to me pretty bigoted to simply assume that a new language that has some similarity to Scala must be a "watered down version of Scala" written by people for whom Scala is too hard. You're less likely to get well-considered answers by posing the question like that. Commented Nov 8, 2011 at 12:27
  • 8
    Assembly is just a watered down version of machine code, right?
    – Zelda
    Commented Nov 8, 2011 at 13:10
  • 6
    @BenBrocka: No, it's isomorphic to machine code ;)
    – user7043
    Commented Nov 8, 2011 at 14:08
  • 4
    Scala is great. As for me, I believe people should give up Java necromancy and bicycles reinventing (all those new languages, mentioned and not) and just use and improve Scala. IMHO.
    – Ivan
    Commented Nov 9, 2011 at 4:08
  • 2
    @MichaelBogwardt a fair point. I'm basing the assertion on what I've seen around the blogosphere. "Scala is too hard" and "Scala is too complex" seem to be relatively common complaints. Commented Nov 9, 2011 at 15:03

6 Answers 6

39

IMHO from somebody programming in Java for the last 7 years and being my strongest language, I find Scala quite alien and am having a hard time getting used to it.

Xtend feels more like Java and was able to write a simple application with it much quicker. Granted I didn't give myself enough time with Scala, but I certainly understand why some may be turned off by it.

With that being said, people will choose a familiar hell over an unfamiliar heaven.

1
  • 20
    +1: "people will choose a familiar hell over an unfamiliar heaven".
    – Giorgio
    Commented Aug 21, 2012 at 7:57
18

JetBrains has a wiki page comparing Scala to Kotlin, and there seem to be a few things that Kotlin does and Scala does not:

  • Zero-overhead null-safety. Scala has Option, which is a syntactic and run-time wrapper
  • Smart casts
  • Static extension functions. Instead of wrapping at runtime
  • Kotlin's Inline functions facilitate Nonlocal jumps
  • String templates. There's 3rd party compiler plugin for scala with similar functionality: ScalaEnhancedStrings
  • First-class delegation. Also implemented via 3rd party plugin: Autoproxy Modules

So calling Kotlin a water down Scala is probably an oversimplification. As for Xtend, I think it targets mostly Xtext users, rather than a wider audience. A major difference to Scala is that Xtend compiles to Java rather than bytecode.

Another "Java killer" language you should add to your list is Red Hat's Ceylon, although I have no idea if and how it compares to Scala.

9
  • 13
    Automatic casts sounds scary.
    – Jonas
    Commented Nov 8, 2011 at 13:07
  • 15
    The industry has these cyclical revolutions where developers will go from one extreme and back again and again. Feature rich power coder languages were good, then idiots wrote bad code and we found the dangers so people flocked to the perceived safety of Java, now back again to power coders. Look at how Javascript and browser based was good, then applets came along and RIA with browser plugins were good and Javascript bad, then modern AJAX frameworks came along and plugins were insecure and bad, then Silverlight came and people said AJAX was dead, NOW HTML5 is vogue and plugins bad again! :)
    – maple_shaft
    Commented Nov 8, 2011 at 13:24
  • 3
    @Jonas I don't even know if I agree with it, but it is a phenomenon that I have noticed. Certainly with each revolution comes a more sophisticated solution, yet each solution always has an Achilles Heel. Solving the Heel problem causes some to look backwards on previous solutions for ideas, but over time people forget why those old solutions were abandoned originally. Over time though, with each revolution, the Heel keeps getting smaller. Java+XTend may certainly not be as sophisticated as Scala, however the problems are smaller than the investment to switch completely to a new language.
    – maple_shaft
    Commented Nov 8, 2011 at 13:54
  • 2
    @Jonas Well, only an extreme high level oversimplification of technological evolution would fit in a comment. I do agree with maple_shaft though, technological evolution does have an iterative feel.
    – yannis
    Commented Nov 8, 2011 at 14:08
  • 3
    @Jonas these cast are not automatic but smart casts: if you look into you will see it is not the same: kotlinlang.org/docs/reference/typecasts.html
    – cy6erGn0m
    Commented Jul 3, 2015 at 9:59
11

I've been using Scala as my primary language for the last year (with Java as a close second, both within a large legacy Java code base.) I still have to look up fairly basic features if I haven't used them in a while. Sure, you can write some Scala quickly, but it's an extremely feature-rich language, and it takes a long time to master.

What's more, its complexity is not just a problem for humans, but also for IDEs and compilers. Both Celyon and Kotlin compile directly to fairly clean JavaScript. Scala can produce JavaScript, via GWT, though getting there is complicated and GWT output is neither legible nor designed to play nicely with external JavaScript or HTML.

I am definitely more productive in Scala than Java, and the code is more compact and legible (once you know a little Scala.) But its complexity makes me hesitate to recommend it to others. A language with 20% of the complexity but 80% of the capability would be a welcome alternative.

[Edited to remove mention of legacy code, see comment below.]

[2017 addendum: Scala now supports JavaScript as a build target, while Kotlin has continued to add features which make sense for a Scala-like Java/Groovy/JavaScript replacement. They are now more distinctive languages than when I first wrote this.]

4
  • Could you please elaborate the "lagacy part" a bit more? For example, which methods do you mean that take Lists rather than Seqs?
    – kiritsuku
    Commented Feb 28, 2013 at 21:31
  • I'm going to edit that, since upon reflection, the standard Scala library actually rarely does that. JSONArray takes a List, but most constructors don't. Regardless, there's still a bias in the documentation toward Lists, particularly since Programming in Scala, 2nd Edition, only covers Scala 2.8, which predates Vectors. And its code examples tend to have constructors which take List where Seq would be better. Commented Mar 1, 2013 at 17:04
  • Yeah, for 2.10 some things are better (+: extractors for example). I hope Programming in Scala will be updated in the near future. For 2.11 some things improve further. The stdlib is already freed from deprecations and will also shrink a little bit. Maybe scala.util.parsing will be moved outside of stdlib too. We will see...
    – kiritsuku
    Commented Mar 1, 2013 at 17:14
  • 1
    I should add that my real problem with Lists vs. Vectors is that adding items to a list (i.e. Seq in Scala) is a very basic operation, and there are too many equivalent ways to do it, all with funny symbols that are hard to remember. The canonical way is ::, ::= or +:= which prepend, but most people want :+= which appends, but that isn't efficient for a List. Commented Mar 1, 2013 at 17:15
10

JetBrains has very clearly stated their objectives for Kotlin:

We want to become more productive by switching to a more expressive language. At the same time, we cannot accept compromises in terms of either Java interoperability (the new language is going to be introduced gradually, and needs to interoperate smoothly with the existing code base) or compilation speed (our code base takes long enough to compile with javac, and we cannot afford making it any slower). The next thing is also fairly straightforward: we expect Kotlin to drive the sales of IntelliJ IDEA.

8

I have used Scala a few months in Eclipse with Play Framework. I like the language but there is also things that I don't like.

For me, the reason to switch from Java to another language is to be more productive.

So far I haven't been more productive with Scala. One reason is the lack of good support for Scala in Eclipse, the Scala plugin is bad (e.g. indentation fails) and doesn't have many functions yet (e.g. no "Open Call Hierarchy"). The Scala compiler is also slow, this may not be a problem, but I use Scala with Play Framework, that compiles the code for every request, and there the compiler speed is important.

1
  • 2
    Maybe you have not learnt enough Scala idioms. I have used Scala for small projects (tools) and I am by far more productive in Scala than in Java, even though I have much more experience in Java (> 10 years) than in Scala (< 2 years).
    – Giorgio
    Commented Mar 1, 2013 at 17:55
4

Don't know about Kotlin, but Scala and Xtend are two very different beasts.

Contrary to common sayings, Scala is NOT a better Java. Scala is much more featured language than Java, with its own syntax and semantics, and its own pack of base libraries.

Xtend IS a better Java. It keeps Java semantics and enhances its syntax. Every line of Xtend code can be directly translated to a bunch of java lines of code. There's no additional runtime, neither.

I think that both approaches are right, although different. I don't dislike Scala (as a language), but don't like having Scala jars added to my projects. I can't use Scala properly in Android, neither (it adds weight and performance issues). Xtend is not as much featured, but it's Ok for me (much worth using it than Java language) and it works on every platform as if I were writing directly in Java.

I believe both languages cover different niches and can coexist without interferring one to each other. IMHO, Scala is just too complex, adding nothing new. Iif you want to go more functional and less OO, just pick one of many simpler functional languages, like Clojure or JHaskell. If you just want Java with some better syntax and a bit of functional programming, Fantom would be as great as Scala (it resembles C# a lot).

But I find Xtend being in a sweet point in between all those languages. It adds all those syntactic patterns I wanted for Java, keeping the good parts of Java (its semantics). Think about it as Coffescript for Java.

And Eclipse support is superb...

3
  • …and it's only supported in Eclipse. Right? And Eclipse is a hell… Commented Nov 29, 2014 at 18:17
  • Xtend does have an additional runtime. About 3MB last I checked.
    – mm2001
    Commented May 28, 2015 at 3:25
  • @mm2001 Yes there are dependencies:about 300 Ko for xtend and 2 Mo for guava on my small test project (github.com/pdemanget/examples/tree/master/xtend/message-send) But it is not a runtime, thes are additionnal classes for thing such as InputOutput, the additionnal annotations. It does not remove the main point to me that Scala and Xtend are 2 very different languages as said in this answer.
    – pdem
    Commented Jul 11, 2016 at 14:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.