“Java 8 got lambdas? Great, goodbye Scala forever!”
Not quite. Oracles new platform drop may have muscled in on Scalas lambda territory, but its no pretender to the functional programming throne.
It’s difficult to take your pet Liger for a walk without
being labelled an eccentric. Equally tricky: unleashing a new
language on the JVM and not being accused of trying to “kill” Java.
Remember all the fuss over
Ceylon? When Scala went live, the reception from some
Java-fatigued devs was equally excitable – at last, here was a hip
young heir to the creaky, conservative platform!
Well, not exactly, as things turned out. Step
Java 8, packed with productivity and
efficiency boosting lambda expressions, methods, references, and
functional interfaces. All those things that had people abandoning
the proverbial Oracle ship for exotic Scala
waters. People are
genuinely excited about the new Java release –
just look at this Twitter sentiment overview below. And it’s this
buzz that’s got many programmers asking the same question: is Scala
at risk of a mass JVM jilting?
— Randy Olson (@randal_olson) March
Not in the opinion of blogger Ahmed Soliman it
seems, who ruminates this very point in a blog post titled:
Java 8 kill Scala?”. For a start, many Java-ites
are just starting to wrap their heads around lambdas (crash
if you’re one of them) but on planet Scala, devs have been
eating these programming functions for breakfast since way back
when. To Ahmed, lambdas in Java simply cannot touch those already
in Scala – at best, they are “scratching the surface”.
Moreover, whilst lambdas are doubtless a big
selling point for Scala, they’re by no means the cardinal feature.
Ahmed notes that the language is also an important tool for users
like himself who want to write reactive, scalable software as
methodically as possible.
Adding lambda expressions to the platform is not
going to magically alchemize Java into a functional programming
language, nor should it. As Ahmed writes, “I see it clearly that
Java is not turning into a functional language…people love Java
for what it is already, the Enterpris-y stuff and solid backward
For Ahmed, closing the gap between Java and
Scala is ultimately a positive for the users on both sides. As he
puts it, what we have now is “two languages that can play even
nicer together now and Typesafe (the company
pushing Scala) is actually excited
about Java 8 as some of us are.”
Going forward, it’ll be far easier for Java fans
to pick up Scala, and conversely, Scala adherents will be able to
learn how Java implements functional programming constructs “to
match the JVM and how the JVM will be adapted (like the recently
added invokedynamic in Java 7) to support the move.”
Moreover, the rapprochement between the two
languages means “support” for the two languages on both sides.
Ahmed cites the Play
Framework, where the Java API of the framework
allows for cleaner code, as a key example of this.
This “peace and love between all the languages”
outlook is shared by
Georges Saab, VP of Software Development in
the Java Platform Group at Oracle, although he notes that whilst he
too believes”new language and runtime features in Java 8 may end up
bringing the various languages on the JVM closer together”, he
sounds a note of caution that “different communities have rather
If a recent TypeSafe survey is anything to go
by, the Scala community is by and large at ease with the
introduction of familiar programming concepts from the language
going into Java. Overall,
48% of users believe that the new
Scala-flavoured addition to Java 8 “validates Scala’s language
design on the JVM and will positively reinforce the adoption of
Scala,” as opposed to leeching away potential users.
Everyone has their
idiosyncratic reasons for developing in the
languages that they do, and adding similar features to ones that
they currently enjoy into another platform isn’t going to suddenly
server these attachments. Where Java 8 could ultimately harm Scala
down the line is if potential Scala users are steered towards Java
A smaller community driving the language
forward would hamper the momentum of
development. Given how conservatively Oracle moves forward with
Java though (and that’s not necessarily to its detriment),
there will always be devs looking elsewhere in the JVM for useful
language features. It’s this agility to rapidly respond to this
demand that will keep Scala and other similar languages on people’s
radars, and keep the community growing – regardless of how many
lambdas you want to stir into your Java.