The two pieces of programming jargon that cause me the most confusion are the words transparent and opaque. They are fairly commonly used, but I have never been fully clear on their meaning.

Google throws up plenty of examples of usage of the word 'transparent', like:

and also a bunch of results for 'opaque', mostly relating to C concepts:

although I've also seen the word used in contexts unrelated to C.

Leaving aside their use within specific compound terms like "opaque pointer", what meanings do the words transparent and opaque have within the sphere of programming? Are they even each other's opposites, like the visual concepts they metaphorically allude to, or are they unrelated to each other?

有帮助吗?

解决方案

In the examples you give, transparent is being used to mean hidden in the sense of things taking place automatically behind the scenes (i.e. without the user of the code or the program having to interact).

Opaque is also being used to mean hidden, which is perhaps where the confusion comes in. The term opaque type has a specific meaning in C/C++, where it refers to a type that has been declared but not yet defined.

In both cases, I think people are using these terms to express a lack of visibility. Transparent is used where something is present, but you can't see it. Opaque is used where something is present, but you can't see inside it to inspect its inner workings.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top