How does code written in one language get called from another language

后端 未结 7 1800
余生分开走
余生分开走 2021-01-31 06:25

This is a question that I\'ve always wanted to know the answer, but never really asked.

How does code written by one language, particularly an interpreted language, get c

相关标签:
7条回答
  • 2021-01-31 07:21

    From a theoretical point of view, when program A need to use resources(class/functions/etc) from program B, it's about passing in some information from A to B, and get some information back or some actions performed. So there needs to be a way provided by B that allows A to pass in information and get result.

    In practice, it usually lies on the shoulder of languages to handle this process: the language B(program B is written in) will generate a protocol and make resources in B available in a predefined way, then language A(program A is written in) will provide some utility/framework to help invocate the exposed resources and get results following B's protocol.

    To be more specific to your question, for interpreted languages, the process is fairly universal, the protocol is normally among the lines of command line parameter, HTTP request and other ways of transmitting plain text. Take the first example, program B will receive a call from HTTP request as input, and then process the request from there on. The actual format of input is totally decided by program B.

    Things like SOAP and etc, are just a way to regulate programs to take input in a commonly agreed standard.

    0 讨论(0)
提交回复
热议问题