Foreign function interface
lastmod 2024-01-08created 2024-01-083 edits
A foreign function interface (FFI) is a mechanism by which a program written in one programming language can use services written in another language or call its functions. The term comes from the specification for Common Lisp, which explicitly refers to the language feature of inter-language calls.
The term is also used officially by the Haskell and Python programming languages. Other languages use other terms: Ada talks about language bindings, while Java refers to its FFI as the Java Native Interface (JNI) or Java Native Access (JNA). Foreign function interface has become a generic term for mechanisms that provide such services.
In most cases, an FFI is defined in a high-level programming language so that it can use services implemented and defined in a lower-level programming language such as C or C++. Many FFIs also provide a way for the called language to invoke services of the host language.