4 Answers
4

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).

@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.
–
PhilotoJun 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.

Thanks! Could you rephrase the last sentence a little? I wonder if you were saying interface and layer mean the same?
–
TimJun 4 '11 at 1:09

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.
–
FumbleFingersJun 4 '11 at 1:29

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.