Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't commons-lang in the java Standard API?

It seems like every java project I join or start on always has commons-lang as a dependency - and for good reason. commons-lang has tons of classes and utility methods that are pretty standard fair with the most standard APIs in other languages. Why hasn't Sun/Oracle/JCP adopted some of the things in commons-lang in to the standard api?

like image 434
whaley Avatar asked Jan 29 '11 15:01

whaley


People also ask

What is Apache Commons Lang for?

Apache Commons Lang provides a host of helper utilities for the java. lang API, notably String manipulation methods, basic numerical methods, object reflection, concurrency, creation and serialization and System properties. Additionally it contains basic enhancements to java. util.

How do I install Apache Commons IO?

Download Common IO Archive Download the latest version of Apache Common IO jar file from commons-io-2.11. 0-bin. zip. At the time of writing this tutorial, we have downloaded commons-io-2.11.

What is lang3?

lang3 Description. Provides highly reusable static utility methods, chiefly concerned with adding value to the java. lang classes. Most of these classes are immutable and thus thread-safe.


2 Answers

As pointed out already, some features in the commons API have made it into Java, often implemented (IMHO) better than they were originally in the commons library. Enums is the classic example.

In terms of why they don't adopt more of commons-lang, well with some classes there's the element of confusion. Take StrBuilder for example, it's more powerful than the Java StringBuilder and it's extensible. But I'm not sure I'd be for adding such a class into the Java core API, StringBuilder/StringBuffer are perfectly good enough for most purposes and having another one in there would really just become a bit confusing. They couldn't really alter StringBuilder in a way that would accommodate all of the changes either because that could break existing code. Even if they did add one, what about when someone else came along with another more powerful version? StrBuilder2? Before long everything's a big mess (some argue that the core API is already, let alone with such additions.)

And as always with these things, the big point is what should be included from commons-lang. Some people would probably want to see the MutableXXX classes added, others the XXXUtils classes, others the time package... there isn't really a common consensus.

The other big thing is that the Java developers have to be a lot more careful what goes in the core Java API than the Apache developers do for commons-lang. If a crappy design in commons-lang is superseded in a future release, the old one can be deprecated and subsequently removed (indeed this seems to be what happens.) In the core Java API it needs to stay for backwards compatibility reasons, just causing more clutter.

For what it's worth though I do think more of the functionality in commons-lang should probably be included. I can just see the reasons, at least in part, why it's not.

like image 82
Michael Berry Avatar answered Sep 19 '22 17:09

Michael Berry


Historically Apache Commons implemented some of the features that later were introduced in Java 5, such as enums and annotations. Their implementation was sufficiently different to make integration difficult.

like image 38
Navi Avatar answered Sep 19 '22 17:09

Navi