
Will Java 8 Kill Scala? - frostmatthew
http://ahmedsoliman.com/2014/03/26/will-java-8-kill-scala/
======
justinsb
It isn't that Java 8 will kill Scala, it is that Scala has demonstrated the
utility of lambdas to the point where they can safely be incorporated back
into Java. So Scala has "won", but in my opinion likely Scala will now fade
away.

Java is necessarily very conservative with adopting language features, because
it is very careful to maintain backwards compatibility. Java is a bit like
Debian stable - out of date compared to Debian testing or even other distros -
but solid as a rock. For features to make it into Java, they really need to be
proved first in other languages or in external libraries.

This isn't the first time Odersky has advanced Java either - he worked on
Pizza, which showed how to add Generics to Java. Scala demonstrates how to add
functional features to Java. Generics were a huge advance, and I think lambdas
will be as consequential.

So if Scala does die, it will be as a sacrificial lamb, rather than as a
casualty of an unseen war.

~~~
eranation
As a Scala and Java developer, I am not even slightly tempted to replace Scala
as my main language for my next project with Java 8. If I'm forced to write
Java, it might better be Java 8, but if I have a choice, there are so many
things (as the OP correctly states) that make Scala compelling for me beyond
Lambdas that just adding that feature to Java doesn't really mean anything to
me. Ruby has Lambdas, so does Python and JavaScript, Dart and I'm sure any
other modern language. I like Scala because of so many other things other than
lambdas that a single comment is not enough.

But to name a few (some were referenced by the OP)

Everything is an expression, For comprehensions (especially with multiple
futures, resolving the callback triangle of death in a beautiful syntax IMHO),
Implicit conversions, Case classes, Pattern Matching, Tuples, The fact that
everything has equals and hashcode already correctly implemented (so I can put
a tuple, or even an Array as a key in a map), string interpolation, multiline
string, default parameters, named parameters, built in dependency injection,
most complex yet most powerful type system in any language I know of, type
inference (not as good as Haskell, but better than the non existent in Java).
The fact I always get the right type returned from a set of "monadic" actions
thanks to infamous things like CanBuildFrom (which are pure genius). Let's not
forget pass by name arguments and the ability to construct a DSL. Extractors
(via pattern matching). And many more.

I think Scala is here to stay, at least for Scala developers, I am 100% sure
you will not find a single Scala developer that will say: "Java 8 got lambdas?
great, goodbye scala forever!". Only reason I can think of is compile time and
binary compatibility. If we ignore those two, all I can say is that this just
proves how Scala is in the right direction (since Java 8 lambdas and default
interface methods and steams are so clearly influenced)

I do wish however that Scala will improve Java 8 interoperability, e.g.
support functional interfaces the same way. and add new implicit conversions
to Java 8 collections as well as take advantage to improvements in the JVM.

I will replace Scala as soon as I find a language that gives me what Scala
does and does it better. So far I didn't find such a language (examined
Haskell, Clojure, Go, Kotlin, Ceylon, Dart, TypeScript, Rust, Julia, D and
Nimrod, Ruby Python, JavaScript and C#, some of them were very promising but
since I need a JVM language, and preferably a statically typed one, it
narrowed down the choices pretty quickly)

Java 8 is by far not even close, sorry. Great improvement, I'm very happy for
Java developers that will get "permission" to use it (might be easier to adopt
than Scala in an enterprise) but this is not a reason for a Scala shop to
consider moving back to Java.

~~~
mushishi
I would use Java 7 rather than Scala in production environment. There are
different reasons, some actually concern language features but one of the
biggest is IntelliJ's capability as Java IDE. It blows away all of the other
alternatives as efficient way of creating readable code that is breeze to
refactor. Even though Java lacks features that make life easier, the lack of
features is important, too. And as a former Scala enthusiast (when it was not
so hot), I just dislike Scala's monstrosity. I have high hopes for Kotlin
because it has some advanced stuff that have been clearly included by the
experience of using Scala. And it in all likelihood will have very good
IntelliJ interop, because JetBrains.

I don't get it why people fuzz over languages without a context of tools.

~~~
bad_user
"Production environment" is a very relative and subjective notion. We used
Scala on the server-side for basically real-time bidding, with the servers
receiving several thousands of requests per second per server instance, with a
total of about 30,000 reqs per sec of real traffic coming in, to which we had
to reply in a maximum of 100ms which included the network roundtrip. Without
Scala, without the ease with which I could juggle with concurrency issues and
asynchronous processing of streams, I couldn't have pulled it off. So in other
words, Java is unfit for a production environment from my perspective.

> _one of the biggest is IntelliJ 's capability as Java IDE_

That's a pretty shallow reason if you ask me, because the speed of writing
code is not the point and IntelliJ IDEA 13 is also very, very good for Scala
development.

> _I just dislike Scala 's monstrosity. I have high hopes for Kotlin_

Well, there's your problem. You thought that Scala is something that it isn't,
like a "better Java". If you approached it like that, without delving in its
FP capabilities that Java 8, Kotlin, Ceylon, Groovy cannot match (or whatever
"better Java" is the fad du jour), then of course it was a bad experience.

Next time you'll have some time to burn, start here:
[http://www.manning.com/bjarnason/](http://www.manning.com/bjarnason/)

~~~
mushishi
Just a quick comment: If I wanted to embrace functional programming, I would
skip Scala and goto Haskell, ML, or Clojure. And if I cared, I should really
dig deep into this subject (tool vs. language). Scala just doesn't fit my
needs. btw. I've preordered that book awhile ago just for supporting it but
not really interested in it.

Becoming professional, and gaining experience has given insight in helping to
choose stack in respect to matureness, stability, tool support, documentation
etc. It's not that you cannot write Scala code for production and be happy
about it. But I rather not. Writing fast is only one part of it. IntelliJ
supports the whole aspect of development cycle, and it's good to hear Scala
plugin is catching up. Just my opinion.

~~~
bad_user
> _If I wanted to embrace functional programming, I would skip Scala and goto
> Haskell, ML, or Clojure._

Interesting choice of languages. Out of that list, only Haskell is suitable
for the argument you're trying to make.

Is that SML or Ocaml? If that's SML, well it's a really poor choice. And what
makes you think Clojure is better for functional programming? I'm not arguing
that it isn't, it's just interesting seeing it in a list of what are supposed
to be better choices for FP. Because in my opinion, Clojure is just as dirty
as Scala or maybe even more so. And it's also a Lisp and the styles and
patterns used tend to be different in Lisps, than what you do in Haskell or
Scala.

That book I linked is not about Scala, but about FP and just happens to use
Scala as the language. It's a good book. If you preordered it, it would be a
waste to not read it.

~~~
mushishi
What I meant is that if I needed to switch from Java to a language that is
oriented towards functional style, I would not consider Scala -- not because
it wouldn't be a good choice regarding FP (I'll leave arguing about how well a
language is suited to FP for others) but because considering all it has to
off, and how its promise was not fulfilled for me -- or maybe it was me what
changed.

~~~
bad_user
Well yeah, maybe you'll like Clojure better. Different style as I've said.

I'm playing with Haskell as well. Cool language, the ecosystem does suck a
little.

------
dkuntz2
"Java 8 has lambdas. Scala has lambdas. Obviously we have to ask the
question... Oh wait, Scala has other stuff too..."

~~~
thejosh
Obligatory
[http://en.wikipedia.org/wiki/Betteridge's_law_of_headlines](http://en.wikipedia.org/wiki/Betteridge's_law_of_headlines)

------
bad_user
Java 8 has the potential to kill languages that were designed with the purpose
of being a "better Java". Scala ain't one of them. Clojure ain't one of them
either.

Surely some people that just want Java with closures will not move to Scala
anymore. Some people that moved because they wanted a better Java, may move
back to Java, because Scala is actually painful when used as a better Java.
But Scala will thrive, as it's a very well designed language that achieves the
best combination between OOP and FP available.

In fact Java 8 is good news for Scala, because of the JVM improvements and
because Java developers will be more comfortable in consuming libraries built
with Scala, like Play and Akka. This is extremely good news, because with the
Java ecosystem being so massive, Scala will gain more users than it will lose
once people start seeing the possibilities.

~~~
pjmlp
Actually I think Java 8 will scare a lot of average skill cog developers still
stuck on Java 1.4 - 6 world.

I just wonder to which language such soulless corporations with move to.

Edit: Why the downvotes?! I do like Java 8.

Just thinking out loud about those soulless corporations I happen to visit
from time to time in consulting gigs.

~~~
larsmak
One great thing about these new language features is that you don't have to
use them. You can run on jdk8 and program as if it was your grandmas vm. This
was true for generics and will be true for lambdas etc. As programmers become
more advanced they understand the need for the more advanced features and
start to adopt them - but they are not strictly required from the start.

~~~
bad_user
To be fair, Java's generics are so awfully implemented that I stay away from
them as much as I can - i.e. invariant, with use-site variance notations by
means of existential types and freaking wildcards (instead of declaration-site
like how Scala does it, which is much saner).

I mean, take a look at this presentation:
[http://parleys.com/play/514892250364bc17fc56bb15/chapter0/ab...](http://parleys.com/play/514892250364bc17fc56bb15/chapter0/about)

And I'm not even ranting about the generics being based on type-erasure, like
so many other people are doing. Type-erasure is actually one of the best
features of Java, since reification implies doing damage in the runtime which
would have impacted other languages and with a good type system, you wouldn't
need reification anyway.

~~~
pjmlp
My two major complaints with generics in Java is lack of type aliases and the
whole issue with primitive types support.

~~~
bad_user
In Scala you can specialize for primitives btw. It has some gotchas, but if
you know what you're doing, it works OK.

~~~
pjmlp
Thanks for the hint.

Actually, in terms of alternative FP JVM languages, I am more into Clojure
than Scala, even though I am a big ML fan.

So I my Scala knowledge is currently at Scala 2.8 level and I wasn't aware of
it.

------
yati
> "the world's most advanced type system that no language can compete with so
> far."

While I love Scala, I'm yet to see a better type system than Haskell's.

~~~
lmm
In Haskell, typeclasses are special-cased and you can only have one
implementation for a given type. In Scala, typeclasses arise naturally as a
pattern out of more primitive building blocks, and are "just another type"
that you can pass around and manipulate in ordinary ways.

~~~
eru
Yes. On the other hand, it's really easy to make a throw-away type in Haskell
as a newtype wrapper.

~~~
lmm
Scalaz's @@ covers many of the use cases, though not all.

------
ninjazee124
I used Scala at my previous startup, but for my new startup I decided to build
the backend in Java 8. Biggest reasons were the tooling/IDE is just miserable
in Scala and the lack of developers in the market. I am really happy with my
decision to build our backend with Java 8, quite a joy to write lambda
expressions and have the tooling of Java.

Pretty sure I won't be going back to Scala.

~~~
mark_l_watson
What are you working on for your new startup?

I think that Java 8 is such a large improvement that I will use Java more
often, and use Clojure less often for back ends.

~~~
ninjazee124
The backend stack is entirely Java 8 built on top of Spring 4 eco system.

------
eranation
I think the article is worth reading albeit the baityness of the title, the
OP's conclusion is by the way:

> So, I don't think Java 8 will Kill Scala by any means.

And he gives valid and compelling reasons why.

------
mpyne
No. Next question...

~~~
kenrose
I mean, the title is kind of link-baity. But the article even answers the
question:

"What about type inference, traits, vals, implicits, case classes, value
classes, static objects, pattern matching, type variance, macros, immutable
datatypes, lazy vals, existential types, higher-kinded types, type classes."

~~~
frostmatthew
> I mean, the title is kind of link-baity.

Agreed, _Why Java 8 is actually good for Scala_ (or even _Java Folks, Welcome
to Planet Lambda!_ ) would have made a better (though less link-baity) title

------
mcv
Scala is a lot more than lambdas. For one thing, Groovy also has lambdas. They
weren't remotely unique to Scala. The real power of Scala comes from other
things, like how you can use the combination of case classes and the builtin
data extracting pattern matchers to easily pass complex messages around.
_That_ is something special.

Lambdas are dead common. They're in practically every language other than
Java, and now finally even Java has them. It's good that Java now gets them
too, but if that was enough to kill Scala, then Scala wouldn't have been
anything special.

------
_pmf_
Scala can safely assumed to collapse under its own weight. Growing a language
by gluing on arbitrary features is not a very smart move.

~~~
mcv
I think it'll collapse under the weight of its type system. The rest of Scala
is great.

------
CmonDev
Maybe using OCAML as a base for F# was a smart move. It seems C# and F# will
be more different than Java and Scala. Yet F# is not different enough to
justify the move in many cases.

------
thescrewdriver
The blog itself basically says that the answer to the question is a rather
obvious No.

