Let’s say I need to use Python and C++. I can call Python function from C++ with Python C API, and reverse is possible with SWIG or equivalent.
How about .NET? I know there are IronPython and C# that finally produces .NET assembly. Is there any well-defined language interoperability mechanism in .NET so that one can use whatever function calls from whatever language?
- If so, what are the mechanisms for that?
- If not, what one can do to call functions from one language to another?
- The .NET mechanism is the same as MONO in terms of language interoperability?
If you’re talking about IronPython and C#, then the two languages can interoperate seamlessly via the CLI (that is, the Common Language Infrastructure). That means, the methods in the C# code are directly accessible from IronPython and vice versa.
For other languages that don’t compile to .NET bytecode directly (e.g. Lua), then you will have to use P/Invoke to call the C API (or use one that someone else has already written, like LuaInterface for Lua).
Mono is basically the same, you just have to be careful with your P/Invoke declarations (i.e. you can’t reference “lua51 .dll” because Linux has .so files, not .dll files)