Language interoperability

Print Print
Reading time 4:29

Language interoperability is the capability of two different programming languages to natively interact as part of the same system.[1] Interoperability is advantageous because programming languages are optimized for specific tasks, and allowing them to communicate can create better systems.

There are many ways programming languages are interoperable with one another. HTML, CSS, and JavaScript are a form of language interoperability as they work together to render webpages. Some object oriented languages can do this thanks to the hosting virtual machine (e.g. .NET CLI compliant languages in the Common Language Runtime and JVM compliant languages in the Java Virtual Machine).[2] High-level programming languages are usually interoperable with some lower level languages, for example Apple's Swift and Objective-C.

Methods for interoperability

Object models

To facilitate interoperability between languages, one method is to use object models. CORBA and COM are the most popular object models. These standards provide a base set of rules for how object oriented languages would implement their data models to allow for a language-neutral way of implementing objects that can be used in environments different from the one in which they were created.

Virtual machines

Different Languages compile into a shared CLI

A virtual machine (VM) is software that emulates operating systems, and acts as a buffer between the language and the hardware. This allows a program to run on any hardware or OS. An advantage to VMs can use these type systems to ensure the correctness of participating languages and gives languages a common ground for their type information. Another advantage is that languages designed for VMs compile into a low level intermediate language. The intermediate language then goes through its own compiler or interpreter which can do more types of optimization.[1]

Challenges

Object model differences

With object oriented languages attempt to pair containers of data with code, but how each language chooses how to do that may be slightly different. Those design decision do not always map to another language easily. An example of this would be how different languages handle inheritance. A single class may have zero (Go), one (Java), or many (C++) superclasses. A common approach to this issue is defining a subset of a language that maps directly to the other, but can also fully understand the other language.[3] This approach does mean in order for the superset to communicate down it will need to wrap some of its interfaces into classes that can be understood by the subset.

Memory models

Differences in how programming languages handle deallocation of memory is another issue when trying create interoperability. Manual and automatic deallocation is not the only issue but if it has deterministic and nondeterministic destruction. Based on the constraints of the language there are many different strategies for bridging the different behaviors. C++ which uses manual deallocation could use a Java styled garbage collector by changing deallocation behavior to delete the object, but not reclaim the memory. This requires that each object will have to manually be deallocated, in order for the garbage collector to release the memory safely.

Mutability

Mutability becomes an issue when trying to create interoperability between functional and object oriented languages. Languages like Haskell have no mutable types, where in C++ there are some constructs to flag classes as immutable but lack support of determining if something is mutable or not. Many functional types when bridged to object oriented languages can not guarantee that the underlying objects won't be modified.

See also

References

  1. ^ a b Malone, Todd (2014). "Interoperability in Programming Languages". CiteSeerX . Cite journal requires |journal= (help)
  2. ^ "Cross-Language Interoperability". Microsoft Developer Network (msdn.microsoft.com).
  3. ^ Chisnall, David (2013-10-01). "The Challenge of Cross-language Interoperability". Queue. 11 (10): 20–28. doi:. ISSN 1542-7730.

By: Wikipedia.org
Edited: 2021-06-18 19:43:07
Source: Wikipedia.org