Sergey Nivens - Fotolia

Java evolution into a functional programming language reflects demand

Many changes have come to the Java languages over the years, with Project Coin and lambda support making it more of a functional programming language.

The Java language and virtual machine are almost two decades old, and while most developers would recognize the old and new models of Java as being related, there's no question that Java has changed profoundly, and the most significant changes may be the ones now coming into focus. Java is transitioning into a functional programming language, introducing direct support for cloud computing and returning to its embedded-device roots, all at the same time. Already the world's most popular programming language, Java may become the most powerful functional programming language as well.

The Java evolution

Programming languages evolve under two separate sets of pressures -- pressure generated by changes in the programmer population and pressure generated by changes in the compute environment. It's these pressures that have driven, and are driving, the evolution of Java.

The first pressure is created by the increased demand for programmers and the pressure to create programs faster and with fewer errors. This pressure was the primary driver for modular or service-oriented programming. Java was first developed at this point.

The second pressure has taken two independent forms. First, web servers, application servers, the internet, multiple-core processors, virtualization and cloud computing have introduced the need to exploit parallel resources -- multiple coordinated execution paths. Second, mobility and internet of things (IoT) are expanding the whole notion of what a compute platform is, changing it from a very smart server and relatively dumb client to a community of cooperating elements of various levels of power and performance.

Java, in its Standard Edition or POJO (Plain Old Java Object) form, was a machine-independent development language based on a virtual machine that could be ported to almost any CPU chip architecture. You wrote programs in Java. An evolved form of Java, Enterprise Edition (EE), combined standard Java tools with middleware elements that facilitated the development of web-driven applications. An embedded or Machine Edition of Java provided lightweight capability for simple devices, including appliances and automobile systems. These editions made up classic Java, and they retain their identity today, as the framework of the Java Virtual Machine alters to support the concept of functional programming in Java 8.

A functional programming language takes a different approach to problem-solving from the traditional procedural or imperative model of programming that all popular programming languages support. The functional programming language approach focuses on defining processes as data transformations, relationships of input and output that are almost an equation or algorithmic in nature. Properly designed, these functional transformations are stateless and fully composable, almost the software equivalent of a RESTful service.

Already the world's most popular programming language, Java may become the most powerful functional programming language as well.

Java 8 adds functional programming through what are called lambda expressions, which is a simple way of describing a function as some operation on an arbitrary set of supplied variables. All of the variables of the expression must be explicitly supplied; you don't access or store data that's not represented as a parameter. This makes lambda expressions more self-documenting, and the code is immune to hidden variables or states called side-effects. You can describe the transformation from input to output in lambda terms, and the details of transformations and recursions are hidden, which reduces complexity and errors. Lambda or functional language expressions can also facilitate parallelism because every variable is always represented as a parameter, so it follows you can run an expression anywhere and it will return the correct result if you give it the correct parameters. You can also split the lambda expression across several platforms and again get the same result. Lambda expressions add functional programming to Java 8, but the traditional imperative model is still available.

Java EE, as noted above, is an enterprise platform for web application development. This means that it has the ability to support multiple front-end elements feeding a back-end transaction processor, a model that's the dominant way that enterprises support web users and mobile users alike. EE7 has added support for additional roles that accommodate cloud-hosting of software. These enhancements recognize that, in the cloud, there are developers of software, hosting of developed software in platform-as-a-service (PaaS) or software-as-a-service form, and software users. The new Java EE7 tools manage all these roles and ensure software evolution and application lifecycle management is accommodated.

Embracing the functional trend

Java EE8 will add a functional programming language capability, and marrying functional language programming with cloud parallelism should create new microservice models for enterprise applications. It also improves the front-end integration, particularly for HTML5 and mobile devices, and also for IoT, and it could be this point that widens Java's appeal and lead over other programming languages. Enterprise JavaScript users will like the fact that Java 8 takes a step to reconverge what has seemed to many to be a divergence of Java and JavaScript, a divergence that's led many enterprises to adopt additional elements like Node.js.

The Machine Edition version of Java is evolving from being simply a lightweight Java for devices to being a machine-client partner element, and that transformation would make it almost an extension of Java EE. The most significant evolution of Java is that it's transforming to be a cooperative, distributed, ecosystem and not just a series of products for different development environments. As such, Java is becoming the first and perhaps only language and middleware combination that's designed for a communication-centric future.

This notion of a distributed community of Java-based processes extends the advances of Java 8 in parallel process support, opening the possibility of developing applications that can expand across cores, processors, and systems with greater ease and less programmer efforts. In theory, it could redefine the notion of the cloud to within and among distributed systems and unify multi-thread computing and cloud computing, at least in terms of design methodology.

The new Java won't be automatic -- as was the case with Java 7 and the PaaS and dynamism features it introduced -- architects and developers will have to adapt their practices and, in some cases, retrofit their software to the new capabilities. It will be worth it; these advances are the most significant in Java history.

Next Steps

How to get Java programmers up to speed on Java EE7

Take a problem-based approach to building a Java application

Lambda, Functional programming, and laws of unintended consequences

Quiz yourself on popular programming languages

Understanding Roc: Functional and separate from the runtime

Dig Deeper on Core Java APIs and programming techniques