0

There are many packages for creating bindings of a library that's written in one language to be called from another language. Some programming languages also include such interop in the standard library, e.g. Julia can call C++ code without having to write manual bindings for it.

With more languages becoming interoperable, it seems inefficient to create and maintain interop capabilities for all pairs of languages, so a generic interface or standard could be valuable. For each language, one would then have to declare what features the language supports and some kind of mapping between the code/binary and the general interface.

Does something like this exist?

7
  • 1
    Microsoft's COM is one example of what such a fairly generic language independent interfacing standard can look like. That takes the approach of asking each caller or callee to implement the types and interfaces defined by COM but not the types and interfaces of all unknown potential counterparts. Some language toolsets have made it easy to interoperate using COM. People working in a Microsoft environment often don't think twice about it. There's a good chance COM is not what you are imagining. But there are many things to learn from it, why it's complex, etc.
    – joshp
    CommentedJun 7, 2023 at 0:41
  • 1
    CORBA is another example of something like that.
    – Mat
    CommentedJun 7, 2023 at 4:31
  • 1
    A little of own research would have brought you to this Wikipedia article(Language interoperability), where you find some technicle options and limitations, as well as more pointers, for example to JVM languages and CLI languages.
    – Doc Brown
    CommentedJun 7, 2023 at 5:23
  • ... and I am not an expert on Julia, but a short look into the docs gives me the impression that for "calling C++ from Julia", one has utilize the Cxx.jl package, so this FFI does not seem to be included in Julia's standard lib.
    – Doc Brown
    CommentedJun 7, 2023 at 6:00
  • 2
    Multiple such interfaces exists (C calling convention, COM, CORBA, SOAP), but none of them have gained universal traction. The problem is languages and runtimes are too different, e.g. how to pass objects between garbage collected languages and languages without memory management? Too many compromises for a one-size-fits-all standard.
    – JacquesB
    CommentedJun 7, 2023 at 7:58

2 Answers 2

5

There are several.

C calls are often the lowest common denominator supported by most languages. The problem is that it does not really support the notion of objects. For objects to be supported you need some standardized way to describe object structure and lifetimes, and there have been several attempts at this:

  1. Compontent Obect Model (COM) is one of the older ones
  2. The Java Virtual Machine can easily interop between all JVM languages
  3. The .Net Common Language Infrastructure allows for easy interop between all CLI languages.

But many languages have intrinsic differences that are difficult to reconcile. Memory management is a big one, and some language features are just not practical without some form of garbage collection. Mutability is another potential problem, if the languages do not agree on what can change or not you will have issues. Not to mention all the possible issues with dynamic vs static type systems. So unless all languages participate in the same interoperability scheme you will have issues. And participating in such a scheme will mean inherent limitations that may not be very appealing to language designers.

A workaround is to use some Remote Procedure Call (RPC) protocol where data is serialized/deserialized instead. That would typically be easier to support by all languages, at the cost of some runtime overhead. See for example Open API or gRPC.

1
  • There are also all the disagreements about types. E.g. in C strings are null-terminated and mutable, but in many other languages they are length-prefixed and immutable. In Python numbers are objects, in many other languages they are primitives. Never mind the numerous different object and inheritance models across languages. You can design a common model on which the languages have to agree, but then you have basically designed a new platform similar to JVM or .net.
    – JacquesB
    CommentedJun 7, 2023 at 8:50
-2

From Interface definition language@wikipedia:

An interface description language or interface definition language (IDL), is a generic term for a language that lets a program or object written in one language communicate with another program written in an unknown language.

IDLs describe an interface in a language-independent way, enabling communication between software components that do not share one language, for example, between those written in C++ and those written in Java.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.