Sorry guys if this seems like a really basic question. I understand how to build applications using a programming language. Now, I read that tensorflow is written partly in C/C++ and Python. I'm wondering why this is done and how you can get multiple languages to interface with each other.
Asked
Active
Viewed 121 times
2
-
4In general, you *write* the implementation in a single language such as C++. Then you *wrap* the interface with bindings to other langauges, such as Python. There are a number of tools and libraries to wrap interfaces such as [swig](http://www.swig.org/tutorial.html) – Cory Kramer Sep 18 '19 at 14:06
-
[Extending and Embedding the Python Interpreter](https://docs.python.org/3/extending/index.html) – user694733 Sep 18 '19 at 14:06
-
Read about creating dynamic or shared libraries. They can be created in any language and used by any language that can interface with them. – Thomas Matthews Sep 18 '19 at 14:09
-
Highly recommend pybind11 – Jeffrey Sep 18 '19 at 14:10
-
No programming language is well suited to everything. C and C++ (which are separate languages - there is no such thing as C/C++) are suited well to some tasks, but not others. Python is better suited to a different set of tasks, and not others. When the effort of interfacing between code in different languages (say, allowing Python to call a C function) is small compared with the benefits of using each language for tasks they work well for, then an application may well be constructed in multiple languages. – Peter Sep 18 '19 at 14:11
-
Maybe this will help you - https://stackoverflow.com/questions/145270/calling-c-c-from-python#145649 – Sid Sep 18 '19 at 14:13