Programming Proverbs 14: Avoid implementation-dependent features

Implementation-dependent features are features or the the hardware or operating system or other part of the platform that is not available on other platforms. For example a specific piece of floating-point hardware or a language feature that is not part of the standard language specification or an operating system API that is not available on other operating systems.

The goal behind this proverb is to create programs that are portable as possible. There are a number of things that have made this both more and less of a problem then it used to be. It is less of a problem because of Virtual Machines that sit between the program and the hardware and base operating system. Java is one such and .NET is another. These virtual machines are able to take full advantage of underlying hardware and software without the applications programmer having to know about it.

At the same time taking full advantage of hardware or operating systems sometimes does require implementation-dependent features. The should be avoided as much as possible but no more than possible. Sometimes one absolutely positivity has to have the most performance possible. At that point one sometimes has to give in an use implementation-dependent features.

In those cases those features should be isolated and compartmentalized as much as possible. By keeping those details separate and independent one can more easily migrate to other platforms with minimized risk.

This is the fourteenth in a series of posts based on the book Programming Proverbs by Henry Ledgard. The index for the series is an earlier post and discussion of the list as a whole is taking place in the comments there. Comments on this "proverb" are of course very welcome here.