In computer science, what are the differences in meaning between interface and layer?

For example, an interface between A and B must belong to either A or B or both, while a layer between A and B must be a third thing that is neither part of A or of B?

migrated from english.stackexchange.com Jun 4 '11 at 16:35

This question came from our site for linguists, etymologists, and serious English language enthusiasts.


In short - interface is what governs the relations between layers.

Interface in computer science (and in IT in general) is nothing more than a contract any entity implementing it must abide. Thus an interface between A and B is a set of predetermined rules, which both must abide in order to communicate properly.

On the other hand layer is separate entity, which may or may not be between other entities. Layer C is between A and B means that there is a separate entity between those two, with it's own interfaces between it and A and between it and B (those interfaces usually are entirely different).

  • Thanks! Do interface and protocol mean the same? – Tim Jun 4 '11 at 5:20
  • @Tim Simply speaking - yes. Protocol is usually a set of interfaces, since it governs relations between sets of entities. Occasionally protocol can be divided into layers, like TCP/IP, which consists of 7 layers and interfaces between them. Although protocols are not always higher level than interfaces. For example, Google API is an interface, governing Google engine in general. And it is a higher level abstraction, than TCP/IP protocol, which can be used as a media protocol underneath the API. – Philoto Jun 4 '11 at 5:50
  • the interface is the rules govern the communication between entities (one also speak of protocol with more or less the same meaning).

  • a layer is a set of entities. Any given entity may communicate only with entities in the same layer, in the layer above or in the layer the below itself, and not with others. Not everything is organized in layers.

  • So what's the difference between interface and protocol ? – Pacerier Jun 20 '12 at 23:07

an interface between A and B must belong to either A or B or both, while a layer between A and B must be a third thing that is neither part of A or of B?

I wouldn't say that an interface must belong to either A or B, but a layer between A and B is definitely a third thing apart from either A or B. "Interface" is kind of an abstract concept; it is a set of rules governing the communication between objects A and B and thus isn't an object itself (although those rules are generally codified by one of the two objects.) A layer however is itself a distinct object or collection of objects related in purpose.

Thing is, the term "interface" depends on more context than just "in computer science". For example, computer scientists often speak of the interface between classes/code modules, but they may also speak of the human-computer interface between the user and the program. The definition of "interface" in each case is slightly different: the former is talking about the public methods or other messaging systems used by the code modules, while the latter is talking about the actual software and hardware widgets that the user is interacting with.


Interface in general has the meaning of:

a surface regarded as the common boundary of two bodies, spaces, or phases.

And layer:

bed; stratum

So, in computer science, the interface of A and B could be C, but a layer of A & B would not be C, if C was the same thing.

  • Thanks! Could you rephrase the last sentence a little? I wonder if you were saying interface and layer mean the same? – Tim Jun 4 '11 at 1:09
  • 1
    In computer terminology an interface is never a layer, though it obviously could be in general parlance. There is a tendency when talking about interfaces to think of them from the viewpoint of the higher-level code. So the 'interface' between the 'database layer' and the 'application layer' often simply means those functions exposed by the former which are called by the latter. – FumbleFingers Jun 4 '11 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.