views:

156

answers:

3

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?

+1  A: 

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.

Gabriel Ščerbák
A: 

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.

Robert Mason
That is the same as using java byte code interoperability for JVM based languages.
Gabriel Ščerbák
And CLR for .NET languages.
Robert Mason
@Robert - perhaps you mean CIL. http://en.wikipedia.org/wiki/Common_Intermediate_Language
Sky Sanders
A: 

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?

Zhang Yining