It is clear that most (if not all) large enterprise services, applications, and so on. (not only the web) are written using more than one programming language. And these components, written in different languages, somehow interact with each other (front, business logic, something else).

I have no experience in developing such systems, so I can’t quite imagine how this happens. I suspect that the interaction goes through language-independent means. For example, something written in one language sends a TCP-IP packet that is caught and processed by something written in another language. Or through HTTP requests. Or through record / reading from a DB. Or through file exchange, XML for example.

I would like knowledgeable people to give a couple of examples, as it usually happens. Not just in a nutshell, they say "the front is on javascript, back on Java", but with technical nuances. Thank you in advance.

Closed due to the fact that the issue is too common for participants aleksandr barakin , user194374, AseN , Alex , Denis Bubnov on Dec 1 '16 at 8:19 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • And what nuances you need. You yourself have listed most of the means of communication. Technical nuances are, for example, functions for working with http in the selected language. Looks at the dock on the tongue. The rest is a matter of fantasy - Mike
  • The most common options you have already led, it is not very clear what else you want as an answer. I will also add that in some languages ​​it is possible to run code written in other languages ​​- for example, a Python script can directly use procedures written in C ++ or Golang. - Xander

3 answers 3

Multiple languages ​​can coexist both within one process, and within several.

The easiest way to coexist is within several processes: if processes exchange data, then it doesn't matter at all (well, within certain limits) in what language this data was created, and what language reads them. For example, you can generate data as an HTML server in ASP.NET, and read it with a browser written in C ++. (Yes, a couple from the server and the client is also a language interaction.)

Now, if we want interaction in a single process, we need to be able to call each other. For this you need a common standard call. Often, such a common standard is binary C conventions ( extern "C" , export from DLL to Windows).

Another example of a common standard - COM : COM objects can be written in many languages, so if there is a part in the language that implements the COM standard, it may well use it.

A separate feature that is currently popular is languages ​​that compile into a common intermediate code. For example, Java and Scala are compiled into the same code for the JVM, therefore objects created in Java are simply available for Scala programs (since accessibility is not determined at the source language level, but at the JVM metadata level). The same applies to .NET-languages.

Well, there is still a set of glue-technologies. For example, to call functions in .NET, there is P / Invoke, which creates an automatic marshalling stub for native functions. (Marshalling requires that data in the “understandable” .NET format be overtaken into data in the format expected by the native code.)

  • And there is also a PHP script in which HTML, JS, CSS, and some JSX, don't remember the night. - rjhdby
  • @rjhdby: Yeah, that’s it. - VladD

If you need exactly the technical details, then see the calling convention. It is these conventions that allow different languages ​​to call functions from libraries written in other languages.

    and with technical details

    Technical nuances are determined by individual standards, specifications, API, agreements. In the process of developing complex systems - there may be several dozen, and sometimes hundreds.

    Simple example "Creating a mail server"

    • Using the SQL query language - a bunch of ISO / IEC 9075 documents *
    • C ++ server side coding - for example, ISO / IEC 14882: 2011
    • Using IMAP4 protocol - rfc1730 + ... a lot of things for encodings and other things
    • Using shared libraries for development - read the call and build agreement for the target operating system
    • etc ...
    • etc ...
    • etc ...

    In fact, the question is very very extensive, there are no nuances here and not close. The approach is simple, we noticed the term you are interested in, the technology, we are immediately looking for what is being standardized. Further, in the process of reading, there will also be a snowball of references to related specifications and standards.