Learning path

Full curriculum

Full curriculum

Unit content

Cross-language linking and foreign-function interfaces

Machine code does not inherently remember which source language produced it. Components written in different languages can interoperate when they agree on a compatible binary interface.

Linkable symbols

A compiled function can expose a symbol that another object file references. The linker resolves that reference just as it would between two files written in the same language.

Foreign-function interfaces

A foreign-function interface (FFI) defines how one language calls code using another language's binary conventions. It may adapt names, data representations, error handling and ownership rules at the boundary.

C-compatible ABIs are commonly used as a portable lowest-common-denominator interface because many toolchains can produce and consume them.

The difficult part is the boundary

Primitive numerical values may cross directly when representations match. Strings, objects, exceptions, callbacks and managed memory often require conversion or explicit lifetime rules.

Cross-language interoperability is therefore less about combining source syntaxes than about establishing a precise contract between independently compiled components.