Programming Languages - Compatibility

Updated: 2019-02-03

Binary vs Source

  • binary compatibility: ABI, code compiled by different compilers to link together and interoperate at runtime. E.g. Swift 5 is not binary compatible with earlier versions, but future versions will be binary compatible with 5.
  • source compatibility: API, old code can be compiled by the new compiler

Cross Languages vs Backward

  • Cross languages: different languages that are either binary or source compatible. E.g. at source level, valid Java code is also valid Groovy code, but not valid Scala code; at binary level all JVM languages are using the same bytecode.
  • Backward compatible: upgrading to a newer version of the language would not break the old code. This is not always guaranteed.

Language Evolution

It is inevitable to introduce new features and deprecate old ones. Different languages handel this differently:

  • Java has @Deprecated annotation for APIs that should not be used. It still compiles but will give you warnings.
  • Python 3 is not backward compatible with Python 2, and that makes the adoption hard and slow. Python 3.0 was released in 2008, and only in 2020 will Python 2 reach end of life.
  • clang-tidy uses modernize- to deprecated old features in C++
  • Javascript's use strict will limit the usage of some old features.