使用多种编程语言开发应用程序

Develop an Application with more than one programming language

我有一个问题困扰了我一段时间,抱歉,如果是菜鸟问题:
有没有一种方法可以使用多种编程语言开发应用程序?
今天我在 Linux 寻找视频播放器,我看到了这个:

MPV Player: Written in C, Objective-C, Lua and Python, MPV is...

谁能解释一下他们是如何用多种语言编写应用程序的?
感谢您的帮助...

您只需要能够从用另一种语言(及其实现)编写的函数调用用一种语言(及其实现)编写的函数。

lua scripting language (and interpreter) was designed to be easily embeddable in C applications. Read the chapter The Application Program Interface of Lua manual (Lua uses some stack for arguments and results). And Guile is also designed to be easily embeddable, and has a nice tutorial 解释说(您将外部函数的数量赋予 Guile 运行时)。

有时,您需要遵循特定的约定(这取决于 实现 )来调用 foreign function. For examples, Python has a chapter on Extending and Embedding The Python Interpreter; C++ code need to annotate with extern "C" the declaration of functions coded in C (or callable from C), Ocaml's manual has a chapter about Interfacing C with Ocaml,等等

更一般地说,请注意 calling conventions and of ABIs. Sometimes, you might want to use libffi,它使您能够调用仅在运行时已知的签名函数。

顺便说一句,MPV is open-source, so why don't you study its source code?

本文将为您解答您的问题: https://www.computerworld.com/article/2467812/internet/polyglot-programming----development-in-multiple-languages.html