On Wed, 2013-02-27 at 17:40 -0500, Nick Sabalausky wrote: > On Wed, 27 Feb 2013 06:57:04 +0000 > Russel Winder <[email protected]> wrote: > > > and Java 8 is a game > > changer that threatens Scala, and Kotlin. > > > > You've mentioned this before in another thread, and you've got me > curious: What aspect (or aspects) of Java 8 are there that make it a > game-changer? > > You've obviously been keeping up on Java developments far, far more > than I have (I've mostly been ignoring it since ~v5 when I jumped > ship to C#/D), so all I know is what I've just looked up on Wikipedia. > The lambdas/closures do indeed sound like a very big deal for Java (I > can't help recalling the infamous old Sun whitepaper that > attempted to show they were unnecessary ;) ). But is there more > *really* significant stuff (I assume there is), or is that the main > reason for Java 8's significance?
The lambda expressions and the default (aka defender) methods in
interfaces remove the need for the vast majority of anonymous classes.
This isn't just a massive shortening of Java code, it is the
introduction of functions as (almost) first class entities to the
language. Lambda expressions are not simply shorthand for anonymous
classes, that would be highly inefficient, the implementation of lambda
expressions is in terms of method handles and invokedynamic. Add to this
call site type inference and the system is really very neat.
The real game changer is the move from always having explicit iteration
to having internal iteration. OK so map, filter, reduce and the like
have been around in languages wince 1957-ish generally and on the JVM
for about 10 years with Groovy, Scala, etc. but to bring this to the
major language, Java, changes the whole outlook for JVM-based
programming — if Java programmer update to Java 8 thinking.
The real point is that this all makes data parallelism trivially easy
for the programmer:
stream.parallel()
delivers up a stream that will be handled with maximum parallelism for
the current platform. OK so it can be abused or misused, but it changes
Java from what it was to something fit for the multicore world without
programmers having to faff around with threads, locks, semaphores,
monitors, and all the low-level stuff applications programmers have been
forced to use for the last 50 years.
Why am I keeping up? I am involved with Groovy
(http://groovy.codehaus.org) and especially GPars
(http://gpars.codehsu.org). I am a member of The London Java Community
(LJC) which has an elected seat on the JCP EC. I am also a bit
associated with the JSR166 work.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:[email protected]
41 Buckmaster Road m: +44 7770 465 077 xmpp: [email protected]
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part
