If your primary goal is Java sans pain, then Xtend, Kotlin, or perhaps Groovy should fit reasonably well and have a gentle-ish learning curve. Both Xtend and Kotlin seem to be designed particularly for this niche, with a dash of Scala-is-too-complex mixed in to their marketing materials.
If you're wanting an interesting new language that goes beyond traditional Java thought patterns, however, Scala (or Clojure) seems like a much better option. Both Scala's type system and its deep and insightful fusion of OO and functional thought make it a far more interesting language to think about and work with.
IMO, YMMV, etc. of course.
For instance, what the heck is the method
GenTraversableLike.++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That
? That is all one method definition. Famous Java-isms like Enum<E Extend Enum<E>> are tame in comparison.
Things like this are the #1 reason I haven't embraced Scala, despite this constant itch I have to learn strongly typed functional programming. And who knows if they might capriciously change Scala tomorrow, like the time they decide to break binary compatibility of type signatures in compiled Scala classes, after which I spent an hour trying to figure out why the heck my IDE was reporting type errors everywhere.
In practice, type signatures written in application code rarely look like that.
Don't get me wrong - Scala is complex. If you don't need the JVM, Haskell is far simpler and cleaner. But you are exaggerating the complexity of it.
I disagree. If anything, both Scala and Haskell are comparable to C++ in terms of complexity. Haskell is in fact, a bottomless pit.
During your descent into madness, you may encounter functors, monads, comonads, free monads, higher ranked types, arrows, zippers, existentially/universally quantified
types, GADTs, kinds, and the other 300 extra compiler extensions that people use on a daily basis.
Documentation is provided in the form of academic research papers.
Not that I'm saying it's not an exciting journey, but it is a long journey.
Everything you mentioned above is just a library on top of this.
In contrast, Scala has java-style subtyping built into the language, along with traits which are a weird mishmash of typeclasses and interfaces. There is quite a bit of complexity surrounding functions/methods. You have implicits to think about. Heck, just look at the type signatures in both languages and compare.
I'm not saying Haskell is easy. I'm just saying they are categorically different kinds of complexity.
Haskell, and to a bit of a lesser extent Scala, have a lot of their complexity arise from combinatorial explosion of interactions of simple features.
Also, relentless abstraction (particularly in Haskell). Yes, you can think of lots of things as arrows. But does it necessarily make it easier to write a particular problem to do so, or does the cognitive load required to maintain the abstraction <-> problem mapping outweigh the benefit of casting it as the abstraction?
Then there's the library, where yes, you see a hairy mess like that. Very difficult to read and understand, but it is a powerful combination of relatively simple and orthogonal concepts. Which doesn't necessarily mitigate the complexity.
FWIW, you rarely need to write code with types that complex, and there is talk in the Scala community of how to simplify the presentation of methods with complex types in the documentation. But that doesn't make it more approachable today.
Would you feel the same way if we applied the situation to English instead of programming languages?
I rather like knowing that there are people who can express thoughts in English that are above my immediate comprehension, and would be loathe to replace English with some other language that prevented them from so doing.
It would feel like Harrison Bergeron applied to programming languages.
What I am saying is that I don't like the costs of investing into a whole another ecosystem (say Scala or Clojure), with an unproven future, and a smaller market (compared to pure Java). Of course, you can call any JAR from Scala and Clojure, but it seems to me that a Scala/Clojure JARs are not equally callable from Java (or other JVM languages). You start getting into runtime JARs and the basic "impedance-mismatch" of different language abstractions. (For example, for languages with traits, what do those correspond to in Java -- interfaces, abstract classes?)
Ideally, I would like to have a language that can compile a Java class that seamlessly interacts with other Java stuff. The problem is that it seems to me you don't get any of the benefits of Scala, Clojure, in that setup, because the runtime adds a lot of value. Most that you could get are nice syntax for lambdas (which are a bit verbose in Java, but not really a problem for me), but those are anyways coming in JDK 8.
Have people on HN thought about this? People who use alt JVM languages, I am curious about your opinions. Honest question, I am not interested in language flamewars.
Datomic is a commercial database system developed in Clojure. The peer library is what you use in your client application to query the Datomic server. The peer library is written in Clojure. I expect that means calling Clojure from Java, and including the Clojure runtime jar in a client application, is safe/stable/supported enough to build a business on top of it.
I'm still learning though, so take what I said with a grain of salt.
However, in my experience, Groovy is about as simple as it can be. Just put your Groovy code inside a class and it looks exactly like any other Java class.
I get that some of the Scala constructs (e.g. traits) may be unweildy to use from Java, but I think you're unlikely to have a large and growing surface area for that. On a case-by-case basis I think you could just provide a Java friendly interface from your Scala code.
Groovy fits the bill.
That has never caused an interoperability issue for me. If there is concern about which method would get picked then use explicit types.
> Xtend is much more interoperable as it binds at compile-time just like Java does and uses the exact same type system
You can enable this in groovy 2 using explicit types and @CompileStatic.
That said, I was having a quiet think while walking in the wilderness recently (I live in the mountains) and I asked myself the tough question: would I have accomplished more in my professional life in the last ten years if I simply always used Java? I honestly don't know the answer but I suspect that the answer is that in some absolute metric of both money earned and productive work for society, just sticking with Java would have been the better call. In the past I have had the same quiet think about just using (J)Ruby.
The big win of being a polyglot programmer is reshaping one's mind to think about problems in different ways, and I don't know if it is worth it.
i wanted to learn either scala or clojure and decide to pick the language with tighter java libraries integration (the language that makes it easier to use java lib), and according the the reviews i read, clojure won in that area
if the level of activity around clojure continues at this rate, i believe it will easily outshine the competition
also dont discount jRuby, it has a nice following
Using Java code from Scala is literally the same as using Scala code from Scala. Same thing if you replace Java with Scala and Scala with Java (with the exception of some Scala constructs that aren't present in Java).
This is not true of Clojure..
looked trust worthy to me!
Approximately nobody codes in Java, rather we code in Eclipse, Netbeans or other Java. It is great because we can still ship the Java code as it is still Java, so I kinda miss things like lambdas and closures, but most of the pain is gone and a lot of things that are still difficult in other languages, such as finding a specific method or class are really easy.
But if you aren't used to program this way, it can take some adjustment.