Quora Feeds
Active Member
Garry Taylor
Lots of options, depending on your choice of languages.
Most languages can work with C. So say one language is C, and the other is Python, Java, C#, Lua, TCL, just about anything else, chances are there is a way to call C code from it. With Java, it’s generally JNI, with Python or maybe TCL it’s SWIG, plus the built in stuff for loading dynamic libraries.
Take Java, you write a Java class which declares some “native” methods, you then run a program called “javah” on that class file, that will give you a C header file. Then you implement the C functions using the definitions in the header file. Compile your C to a library, and Java can then load that up and start calling the C functions. It’s pretty cool.
If you don’t want to actually load up a dynamic library, you’ve got message passing, there are variants of this like MPI, or you can roll your own.
Then there is shared memory, basically you allocate some memory, mark it as shared, and you can have other processes access it. Doesn’t matter what language those processes are written in, so long as they can access shared memory regions.
Or of course, just run stuff. No reason you can’t call a Ruby script from Python, just run it, passing parameters, and reading the output.
See Questions On Quora
Continue reading...
Lots of options, depending on your choice of languages.
Most languages can work with C. So say one language is C, and the other is Python, Java, C#, Lua, TCL, just about anything else, chances are there is a way to call C code from it. With Java, it’s generally JNI, with Python or maybe TCL it’s SWIG, plus the built in stuff for loading dynamic libraries.
Take Java, you write a Java class which declares some “native” methods, you then run a program called “javah” on that class file, that will give you a C header file. Then you implement the C functions using the definitions in the header file. Compile your C to a library, and Java can then load that up and start calling the C functions. It’s pretty cool.
If you don’t want to actually load up a dynamic library, you’ve got message passing, there are variants of this like MPI, or you can roll your own.
Then there is shared memory, basically you allocate some memory, mark it as shared, and you can have other processes access it. Doesn’t matter what language those processes are written in, so long as they can access shared memory regions.
Or of course, just run stuff. No reason you can’t call a Ruby script from Python, just run it, passing parameters, and reading the output.
See Questions On Quora
Continue reading...