Why *Even You* Should Care About Java Code Libraries

Java has been a top-ranked programming language for years, thanks in part to an enormous set of libraries that developers can assemble to perform just about any task.

Java has been a top-ranked programming language for years, thanks in part to an enormous set of libraries—both bundled with the software and available free in open source repositories—that developers can assemble to perform just about any task.

Given the pressure felt by companies in every industry to innovate quickly and efficiently, the importance of enabling their IT staff to reuse a large body of existing, tested code cannot be overstated.

Java-getstarted-bnr-2244507

In many respects, Java’s wide array of libraries—collections of precompiled routines—has transformed the nature of programming. Prior to the release of Java in 1995, languages tended to have small built-in libraries, and third-party options were few and expensive. When companies began a new project, developers had to write the software entirely from scratch. Each IT department had its own collection of routines written in-house—generally at considerable cost.

With the Java model, however, the nature of this work changed. Developers could specialize more, leaving standard functionality to the libraries while writing only the unique routines not available from existing libraries, along with the so-called glue code that enabled library X to interact with functions from library Y. The extraordinary increase in software production during the last 20 years is a direct result of the proliferation of libraries.

All About Ecosystem

Depending on which measure you use, Java is either first or second in popularity among programming languages for new-project development. It has held this top rank for many years, due primarily to what is referred to as its ecosystem.

A language’s ecosystem consists of several key components: the language itself and the software that implements the language, software-development tools (language-specific development environments, debuggers, performance profilers, and so on), and libraries. Secondary elements—such as books and tutorials, meetups, and conferences such as JavaOne—also contribute greatly to the development of an ecosystem and its community of developers.Each of the principal components in Java is exceptionally robust, but among them it is the vast number of Java libraries that most stands out.

3006441-poster-javva

Libraries by the Thousands

Libraries are groups of related functions. For example, one of the core libraries in Java handles strings—that is, sequences of characters, such as letters and numbers. This library contains functions that measure a string’s length, truncate a string, pad it with spaces or zeroes, search it for a specific substring, capitalize it, and so forth. As in most languages, Java libraries fall into two major categories: those that ship with the language and those that are written by third parties.

While Java originally shipped with a limited set of libraries, it now bundles a large contingent that is considered part of the core language. These libraries vary from handling networking issues to doing arithmetic on arbitrary-length numbers (literally, on numbers containing thousands of digits). Few languages today match the set of libraries that ship with the Java language.

Public repositories of libraries such as the Apache Software Foundation,Bitbucket, GitHub, and SourceForge also host thousands of Java libraries that perform almost any conceivable task. Want to create a Microsoft Word document, convert it to PDF, and send it as an email attachment to a remote document server where it will be analyzed for keywords and indexed for later retrieval by a search engine? For every one of those tasks—including the search engine—a high-quality Java library exists.

The Java Advantage

It’s important to note that Java did not pioneer this library model. (Users of the language Perl did.) Java has certainly expanded the model beyond any other language, however.

It’s also worth noting that not all languages use the same model. For example, C# and the other Microsoft languages depend on a smaller library ecosystem, which is by and large commercial. That approach has spawned a cottage industry of small businesses that write (and sell) libraries for .NET-based applications. Meanwhile, with the exception of some database drivers, all Java libraries of which my colleagues and I are aware are free and open source.

It’s not hard to see how an ecosystem with tens of thousands of well-crafted libraries available at no cost can be a potent advantage for Java. But even sites that use multiple languages in a single project—so-calledpolyglot programming—benefit. For example, a common combination of languages is Java and JavaScript. (The latter, which bears a confusingly similar name, is an unrelated language used primarily for web applications.) Most projects use the languages for separate components, with the majority of the logic written in Java and much of the user interface in JavaScript. However, if developers wanted to use JavaScript inside Java portions they could, because—you guessed it!—a library called Nashorn, which is bundled with the core Java platform, enables JavaScript to be run within a Java program.

One of the principal reasons Java is considered foundational in so many enterprises is its ecosystem, especially the numerous libraries, which enable developers to quickly implement almost any function they need.

 

Source: Oracle

Leave a Reply

Your email address will not be published. Required fields are marked *