我可能是这里的少数派,但从我学过的所有学术/职业生涯中,我都学过不同的语言。 在此期间,语法和编程范例成为焦点,但我们从来没有教过关于使用不同语言编写的系统以及作出此决定的适当方式。
现在为了记录,我不是在谈论规范的Web栈或更新,更性感,适用于JVM的语言。 我想知道的是,如果有“已知资源”,我可以在其中了解绑定语言(例如Java和C ++)背后的决策过程。
诚然,XML,JSON和XMPP等工具都浮现在脑海。 然后,我再次看到使用序列化绑定Java和C ++的系统。 我不是在寻找一种解决方案。 我更感兴趣的是了解各种解决方案以及我应该如何做出这样的决定。
我很抱歉,如果这个论坛太广泛了,但至少我不会要求人们纠正或重写我的代码;)
I may be the minority here, but it seems through my entire academic/professional career I've been taught varying languages. During this time, syntax and programming paradigms were the focus, but at no point were we taught about integrating systems written using varying languages and the proper way to make this decision.
Now for the record, I'm not talking about the canonical web stack or the newer, sexier, JVM-friendly languages. What I'm wondering is if there are "known resources" where I could learn about the decision making processes behind binding languages like, Java and C++, for example.
Granted, tools like XML, JSON and XMPP come to mind. Then again, I've seen systems binding Java and C++ using serialization. I'm not looking for a one-fix-for-all type of solution. I'm more interested in learning about the varying solutions and how I should be going about making such decisions.
My apologies if this is far too broad for this forum, but at least I'm not asking folks to correct or rewrite my botched code ;)
最满意答案
我能想到的有四种不同的模型:
在主要用更“系统”语言编写的应用程序中嵌入动态语言,如嵌入Java,C ++或C#应用程序中的Lua,Python或Javascript。 这主要用于应用程序的脚本/自定义组件。 这将通过以动态语言可以使用的格式公开一些主机应用程序数据类型来完成。
为具有性能问题的语言编写本地(或C#或Java)扩展。 Python和Ruby有很多这样的扩展。 这与上面的不同之处在于动态语言是框架。 这是通过编写本地库(或其他本地库的包装)来实现的,以符合客户端语言的调用约定。 当在系统代码中将汇编程序与C混合时,这也是相同的一般结构。
在不同的地址空间中运行应用程序,并通过套接字或管道进行通信。 在这种情况下,应用程序运行在同一台机器上只是一个巧合 - 它们也可以通过网络进行交流。
使用共享相同平台和调用约定的多种语言开发应用程序。 例如,Java和Scala可以自由混合使用。
There are four different models that I can think of:
Embed a dynamic language inside an app that is primarily written in a more "systems" language, like Lua, Python or Javascript embedded in a Java, C++ or C# app. This is used primarily for a scripting / customization component to the app. This will be accomplished by exposing some of the host applications data types in a format that the dynamic language can make use of.
Write native (or C# or Java) extensions for a language with performance problems. Python and Ruby have lots of these extensions. This differs from the above in that the dynamic language is the framework. This is accomplished by writing the native libraries (or a wrapper around other native libraries) to conform to the calling conventions of the client language. This is also the same general structure when intermixing assembler with C in systems code.
Run the applications in different address spaces and communicate over sockets or pipes. In this case, it's just a coincidence that the applications are running on the same machine at all -- they could just as well be talking over the network.
Develop the app using multiple languages that share the same platform and calling conventions. For example, Java and Scala can be intermixed freely.
更多推荐
发布评论