Is Java Dead or Invincible?
Is Java Dead or Invincible?
Join the DZone community and get the full member experience.Join For Free
Take 60 minutes to understand the Power of the Actor Model with "Designing Reactive Systems: The Role Of Actors In Distributed Architecture". Brought to you in partnership with Lightbend.
According to Dutch research firm Tiobe in terms of overall popularity, Java ranked 5th in 1997, 1st in 2007 and 2nd in Sept 2012. At the time of writing there are over 2,000 Java progamming books on Amazon in English and there are almost 300,000 threads on Stackoverflow related to Java. However, as George Orwell once said: "Whoever is winning at the moment will always seem to be invincible". But is Java invincible or beginning to die? That's the question being asked more and more now.
In my humble opinion, the challenges to Java can be split into three categories:
- The rise of alternative languages
- Scalabiility / Multi-Core processors
- The return of the fat client.
The rise of alternative languages
and those that don't (Python, Ruby). Well, the interesting thing is that the first group is pretty large. The languages that run on the JVM aren't mutual exclusive to Java and in a sense strengthen it reminding us what a remarkable piese of software engineering the JVM is. Development teams can get that
extra bit of expressiveness in a niche language like Groovy, but can still call out to Java when they need some cool Java library or just need that extra bit of performance. Remember the advantages in Groovy 2.0 speed it up but it is still not always as fast as Java.
As for the features some of these languages provide that are not in Java, well that is the case but it won't always be the case. Take a look at the roadmap for Java 8 and the features it will include. Just like Java EE 5 and 6 took ideas from Spring / Seam, the Java lanuage in its 8th major release will be taking ideas from other languages. For example literal functions will be facilitated by Lambdas. These Lamdas will have support for type inference and because they are just literals it will be possible to pass them around (and return them) just like a String literal or any anonymous Object.
That means instead of having to write an implementation of Comparator to pass to the Collections sort utility to sort a list of Strings, in Java 8 we will just do:
Collections.sort(list, (s1, s2) -> s1.length() - s2.length());
So, the alternative JVM languages don't exactly kick Java out of the party. It is still there, but in a party that has a better selection of music played and in a party where the guests encourages their host to be a better host.
Scaling on the multi-core platforms
So what's the deal here? Firstly, even though concurrency and threads were a feature of Java from the very beginning the language support was limited meaning developments teams were writing a lot of their own thread management code - which could ugly very quickly. This was alleviated greatly in JDK 1.5 with the arrival of a range of thread management features in the java.util.concurrent package. Secondly, to get better parallelism something else was needed. This came in Java 7 with Doug Lea's Fork / Join framework which uses the clever techniques such as work stealing and double sided queues
to increase parallelism. However even with this Framework, decomposing (and re-arranging) data is still a task that is needed to be done by the programmer.
Functional progamming gives us another option to perform computations on data sets in parallel.
In Scala, for example, you just pass the function you wish to operate on the data and tell scala you want the computation to be parallelised.
outputAnswer((1 to 5).par.foreach(i => longComputation))
And guess what? The same will be available in Java 8.
Array.asList(1,2,3,4,5).parallel().foreach(int i ->heavyComputation())
|The fat client is back!|
The return of the fat client
- Yammer and their migration to scala
- James Gosling taking about the state and future of Java at Google tech talk
- Article from Oracle describingFork and Join in Java 7
- Eric Bruno:Building Java Multi-Core applications
- Edgardo Hernandez:Parallel processing in Java
- IEEE top ten programming languages
- JDK 8 downloads
- Java Code Geeks article on Fork Join
- Good Fork Join article by Edward Harned
- Fork / Join paper from Doug Lea
- Fork / Join Java updates information from Doug Lea
- Scala Java Myths - great article by Urs Peter and Sander van der Berg
Published at DZone with permission of Alex Staveley , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.