语言互操作性的最佳实践是什么?

发布于 2024-08-30 19:57:36 字数 52 浏览 2 评论 0原文

在需要使用多种语言的系统中,当代码调用另一种语言的代码时,确保松耦合架构的最佳实践是什么?

In a system which requires use of multiple languages, what are the best practices to ensure a loosely-coupled architecture when code is calling another language's code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风夜微凉 2024-09-06 19:57:36

用 C 语言编写 API。许多现代语言都可以轻松调用或合并 C 代码。 C++、Vala、Python、D、C#、Many Lisps、VB 和 Java(仅举几例)允许在共享库中使用 C 代码。通过这种方式,只要您有一个健全的界面,您就可以轻松地从大多数任何语言调用您的代码。 C 是现代计算的最小公分母。

Write the API in C. Many modern languages can call or incorporate C code with little to no hassle. C++, Vala, Python, D, C#, Many Lisps, VB, and Java, just to name a few, allow the use of C code in shared libraries. In this manner, as long as you have a sane interface you can easily call your code from most any language. C is the lowest common denominator of modern computing.

朱染 2024-09-06 19:57:36

嗯,这是一个很难的问题,答案 iMHO 取决于语言交互的方式。您可以使用某种消息传递接口、消息队列甚至一些中间件,例如 CORBA 甚至可能是 Web 服务。例如,对于 JVM 语言,您可以使用虚拟机(脚本引擎)提供的互操作性功能。也许如果您提供更多详细信息,我们或其他人将找到一些可用的解决方案。

Hmm, this is quite a hard question, the answer iMHO depends on the way the languages interact.You can use some sort of message passing interface, message queue or even some middleware, e.g. CORBA or even maybe web services. E.g. for JVM languages you can use the interoperability features provided by the virtual machine(scripting engine). Maybe if you give more details, we or someone else will get to some usable solution.

错々过的事 2024-09-06 19:57:36

IMO,在您至少可以详细说明问题中提到的“系统”之前,无法回答这个问题。例如,“系统”是指一部手机、一台机器、一个虚拟机(如 JVM 或 CLR)、一组位于 LAN 或跨互联网的服务器吗?不同种类的“系统”,有不同的最优解,您能详细说明一下吗?

IMO, there is no way to answer this question before you can at least elaborate on the "system" mentioned in the question. Is the "system", for example, a mobile phone, a single machine, a virtual machine like JVM or CLR, a group of servers on a LAN or spanned across the internet? In different kinds of "systems", there are different optimal solutions, so could you elaborate a little more?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文