Software Version Numbers are Weird
January 28, 2025
It is important to install the right version of dependencies, libraries, and software to obtain the desired features. I made the mistake twice thus far where I
misunderstood version numbers. Here’s my grievances about how software versioning system works in how incompatible it is to the numbering system we use in our
everyday life. Let’s look at FileUtils.readFileToString()
:
public static String readFileToString(File file,
Charset charsetName)
throws IOException
Reads the contents of a file into a String. The file is always closed.
Parameters:
file - the file to read, must not be null
charsetName - the name of the requested charset, null means platform default
Returns:
the file contents, never null
Throws:
NullPointerException - if file is null.
IOException - if an I/O error occurs, including when the file does not exist, is a directory rather than a regular file, or for some other reason why the file cannot be opened for reading.
Since:
2.3
I am trying to compile some Java framework into a Jar at work and encountered an issue with readFileToString()
. As specifying Charset
is only available in
version 2.3 of commons-io
, I “upgraded” the version in pom.xml
. It turns out I downgraded because 2.3 < 2.15
and not the other way around.
In Math, 2.3
and 2.30
are the same thing. In science, these have the same quantity but differ in precision or certainty of the measurement. However,
in software, version numbers work differently. The common pattern is <major>.<minor>.<patch>
which is commonly abbreviated as x.y.z
. When comparing between
two version numbers, one must order by looking at the major, minor and patch number as separate whole numbers and not as a number. Of course, 1.1.1
is not a number
but I am blind. If you compare the major, minor, and patch separately, you can easily realize that 2.3 < 2.30
because 3 < 30
or 2.3 < 2.15
because 3 < 15
.
Edit: One way to compare version numbers is to think of comparing it as if it’s a coordinate except there is a precedence order of the coordinates where one
compares the value in the first slot x
, then second slot y
and then lastly z
before determining if the two versions are equal.