Java 与 C++ 相比的向后兼容性

Backward compatibility in Java compared to C++

我用 C++ 编写代码有一段时间了,我已经习惯了平台兼容性问题。但是现在,我意识到向后兼容性是另一个重要问题:

How can the Boost libraries be used successfully for important projects?

Many of the Boost libraries are actively maintained and improved, so backward compatibility with prior version isn't always possible.

(来源:http://www.boost.org/users/faq.html

Java有同样的问题吗?我知道每个包的情况都不一样,但是 Java 与 boost 一样出名的包在 C++ 世界中怎么样?

您已经方便地在 Boost FAQ 上截取了其余答案,它告诉您如何处理这个问题:

Deal with this by freezing the version of the Boost libraries used by your project. Only upgrade at points in your project's life cycle where a bit of change will not cause problems. Individual bug fixes can always be obtained from the boost repository.

至于你剩下的问题...

Does Java have the same issue?

当然可以。这不是特定编程语言的问题。一般来说,这是第 3 方库或框架的问题。

I know that the situation is different from package to package, but how about Java packages that are as much famous as boost is in C++ world?

Java 没有什么比 Boost 更好的了,因为 Boost 提供的许多东西已经是 Java 框架本身的一部分,无论好坏。想想字符串算法或文件系统操作。

话虽这么说,也许 Apache Commons comes close. As it turns out, it has its own share of backward compatibility issues -- which, as I said above, is completely normal. For example, the release notes for v4.0 清楚地说明了以下内容:

This version uses the generics features of Java 5 and is not compatible with earlier JDK versions.

(...), we have chosen to break the API in various ways. (...) We have also removed all deprecated classes and fixed oddities in the previous API that we couldn't fix due to backwards compatibility restrictions.

请记住,Boost 和 Apache Commons 都以非常专业和 well-documented 的方式处理这个基本 software-engineering 问题。不幸的是,无论使用何种编程语言,您在野外遇到的大多数其他库和框架都不是这样。