How does a program composed of several languages work? How do the languages work together or interact with each other? How do they understand stand each other? How do you know when to use any given language and how do you implement them so they work together? (Not in terms of strengths and weaknesses but in terms of task and function). This isn't a WHY would you use multiple languages question but a HOW would you use multiple languages question.

Feel free to direct me towards any resources that may prove helpful in my quest for understanding.

  • 3
    It depends entirely on the combination of languages you're talking about; this is way too broad for one Q&A. But some tips that might help you Google things: A few languages have this as a major design goal (e.g., Lua), many languages provide some form of FFI (foreign function interface) to make this less painful, and APIs that need to be callable from all languages (system calls, OpenGL, etc) are often exposed as a C API since C is sort of a lingua franca.
    – Ixrec
    Mar 30, 2016 at 8:18
  • 2
    Oh, I forgot an obvious one: Most networking protocols and file formats are completely language independent, so it's almost trivial to make a Python program and a Java program talk to each other via HTTP requests/responses or .txt files or whatever.
    – Ixrec
    Mar 30, 2016 at 8:33
  • This indirectly answers your question: stackoverflow.com/questions/4546941/…
    – slebetman
    Mar 30, 2016 at 9:17

2 Answers 2


Interfaces between languages tend to be at the "lowest common denominator" level. Java knows nothing about C++ classes, C++ knows nothing about Python, and so on. So all you're left with is simple function calls and primitive types, such as integers, floats, and arrays of characters for strings.

In practice, this "lowest common denominator" is often C. Many operating systems these days are written in C and/or C++. So there will be a C compiler, a C standard library, and a C API to the operating system (e.g. Win32 on Windows).

Ideally, avoid using multiple languages for one application, as it gets messy. If you must, then you need to design a clean and simple interface between the two, just using simple function calls. It's almost like writing two separate programmes that talk to each other.


A program which uses multiple programming languages is rather uncommon. It should usually be avoided unless there is a good reason to do so, because it increases the necessary know-how which is required to maintain it.

A technology which allows to implement different parts of a program in different programming languages is Microsoft's Common Language Runtime which is targeted by the .NET-based programming languages. This works because all CLR-based languages compile into the same bytecode format which is then executed by the CLR. The CLR is object-oriented and the primitive data types are standardized, so a class programmed in one language can instantiate and use objects of a class programmed in a different programming language.

Another thing you see from time to time are programs which use scripting languages (like a game engine written in C++ which uses scripts written in LUA). In that case the program uses a library to interface with the scripting language interpreter. It passes the script sourcecode to the library as a string and then gets a set of library functions to tell the scripting language to execute that code.

And then you have larger projects which consist of several independent programs which communicate with each other via network. You can, for example, have a HTML+Javascript application running in a web browser which calls a PHP backend running on a webserver which calls a C++ database running on an application server. Although these are all different programs from the technical perspective, they look like one application from the users perspective. The individual components do not need to concern each other with which technology the other components are implemented in because all communication is via standardized network protocols.

  • "A program which uses multiple programming languages is rather uncommon. It should usually be avoided unless there is a good reason to do so" You are not using much Python then. There for example it's a daily usage case that you use a module which is written in C/C++ to write glue code in Python using it. Usually the part written in another language is written by someone else though. Mar 30, 2016 at 11:57
  • 1
    @Trilarion No, I am not using any Python. I don't need to because I know enough C++ to glue C++ modules together natively :)
    – Philipp
    Mar 30, 2016 at 12:03
  • 1
    Most C++ projects I know use multiple languages: at the very least C++, C preprocessor, make, and sh. And then there's this weird Prolog-Haskell-like lazy-functional-logic hybrid language with funny syntax called "template metaprogramming". Mar 30, 2016 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.