Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language integration

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 ;)

like image 411
John Claus Avatar asked Dec 23 '22 09:12

John Claus


1 Answers

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.

like image 107
Kevin Peterson Avatar answered Dec 28 '22 06:12

Kevin Peterson