See all glossary terms

Interface

Because most programming is text-based, names are the main way we interact with external code. To use code written elsewhere, we need to know which keywords we can use, and how to use them.
At a high level, an interface is a contract that defines the ways in which an object can be used. When we say that an object implements an interface, it means we know in advance the methods and properties the object has, and how to use them. We don't need to know how the object works inside. This is the essence of Encapsulation.
GDScript doesn't have interfaces enforced by the language like Java or C#. Instead, GDScript uses duck typing: If an object has the methods and properties we expect, we can use it as if it implements an interface. This is a more flexible approach, but it also means we need to be more careful when using external code: since the engine doesn't check the interface for us, it is more error prone.

See Also

Related terms in the Glossary