Hi! I was wondering how programs that make use of several languages work. They'll have several files of data and several languages worth of code. I heard before you can use Python as "glue", to put string together the different code. However, I don't know how I'd even go about that in Python.
Every time I try to search this up, I find nothing particularly useful. Examples or explanations would be very helpful, thanks!
In the particular case of Python, there's two ways an external language can interact with it:
1. Extension: The Python interpreter is the main process, and it loads a dynamic library that implements specific functionality (e.g. graphical output, or data compression) in such a way that can be exposed to the Python program.
2. Embedding: The main process is a C program or a program in a language capable of loading C functions, and it loads the Python interpreter as a dynamic library. Once the interpreter is loaded and initialized, it can load Python code and execute it. The C program can also expose some of its functions to the interpreter, so the interpreted program can call back to the C code.
as much as is possible I prefer to keep it in a binary format (dll /so ) that more or less ignores the original language. This is not always possible if you have a bunch of scripting.
Thanks a lot guys! That makes a lot of sense. So you write the code, make it into a DLL, and then Python can be the language interacting with all the DLLs.