Launching other Programs with C++

Hello, I've heard that C++ is not the best programming language for web crawling. I want to use C++ so that it launches a background python process to generate some data for the internet, and let C++ do the processor intensive tasks, such as natural language processing, and then relay some information to the python program so that it can look for more links, and repeat this process.

Is there any simple way I can do this? I've heard of CORBA, but it seems very complicated.
There are three ways to solve this problem.

One is to launch the python interpreter simply as an external program. You can use Qt library (QProcess) for example if you want it to be cross-platform. This is probably the simplest way to do it.

The second way would be to create a library and expose it to python using a tool such as SWIG. This also should not be difficult.

The third way is to incorporate a python interpreter directly in your program. This approach is a bit more messy in my opinion.

Overall it's up to you to choose your approach. You need to consider in which language will your main application be written, how reliable and platform-independent should your code be and how much effort are you willing to put in it. I didn't have any experience with CORBA myself, but I believe that it really is more difficult than all the three approaches I described.

Hope this helps a bit.
Last edited on
Thanks! I think SWIG sounds like the best option, does the tool make the process run inside the program? i.e, there would be no need to launch an external application, which would severely effect the efficiency and performance of the program?
Basically, the binding generators (such as SWIG) allow you to use the c/c++ shared libraries within the python code using Python-C API. So basically the Python interpreter directly executes the library code and there are no additional processes being run. There is the overhead of type conversions and checks, but it is not high if you really use C++ the bottlenecks in your code.

Apart from SWIG you may also look at Boost.Python and Py++ (which is a code generator for Boost.Python). It depends on your preferences in writing code and whether you want to expose your C++ functionality to other scripting languages (SWIG can do that, while Boost.Python cannot).
Hello, I've heard that C++ is not the best programming language for web crawling.


It depends of your programming skills. A web crawler parses the html response received from the server to find more links ...

GNU wget is written in C, it is open-source and has web crawling functionality (maybe there is other C/C++ libraries that do the same thing).
Topic archived. No new replies allowed.