Why is artificial intelligence driven by Python and not C++?
Tags: c, cpp, python, machinelearning
Published: 2020-07-04 18:49:30

In short, for _**Productivity**_.

If you want to know further , you have to go through all of it.
_**Python**_ is not the one and only solution for _**Artificial Intelligence**_ , _**Data Science**_ , _**Deep Learning**_ , _**Neural Network**_ etc. Rather _**C++ , .NET , Java , JavaScript , Prolog , Julia**_ are some frequently used Ecosystems for those. But we heard too much about _**Python**_ that nowadays we assume  _**Artificial Intelligence**_ , _**Data Science**_ , _**Deep Learning**_ - these things only run on the top of _**Python**_. Truth is far from this.

Basically there are two types of languages.
* _**Performant Language**_ e.g. C , C++ , Asm , B.
* _**Productive Language**_ e.g. Python , JS , Java , Kotlin , Swift.

_**Python**_ is a _**Glue Language**_ which combines the higher level API's of different libraries & makes easy to use. Under the hood , those Libraries are mostly written in _**C/C++**_. The history of using _**Glue Languages**_ for scientific research are more older than we actually think. Programmers used to write their code using _**Perl**_ & _**TCL**_ back. _**Python**_ is more popular nowadays.

Now you might ask 
> "Why Glue Languages ?"

Assume you are working on a _**Neural Network**_ project which requires you to solve a few hundred problems or you might need to solve the same problem multiple times using multiple ways to figure out which one is the most efficient. For such tasks you need to choose a language in which you can turn your ideas into code , see results and make changes if you need as fast as you can. _**The more you are faster in this testing step ,  the more productive you will be**_. This is the reason why programmers don't want to mess with Low level stuffs here.

Think what will be the impacts (both advantages & disadvantages) of using _**C/C++**_ for such projects.

**Advantages**:-
* Performance will be grate if code is well optimized.
* You can manage memory however you want.
* You will have control over every single line of low level code base.
* Data processing rate will be much faster.

**Disadvantages**:-
* Low level stuffs like Memory Management , Data Type , Pointer will require a great attention and huge time which is a red mark for faster development.
* Events like Exception handling will be a headache in this case , cause _**C/C++**_ is unmanaged language.
* You might need to re-write some parts or the whole of some useful libraries or frameworks for _**C/C++**_.
* You need to mess with things like Memory Leak / Overflow , Garbage Management.
* You will need more time & development cost might rise.
* Maintaining your codebase will be a nightmare.

Optimizations such as performance or others can be done at _**Deployment Stage**_. But programmers usually don't bother with those at _**Development Stage**_. They basically chose languages keeping two primary keys in mind , they are:-

* How much productive the language is.
* Whether plenty of useful libraries / frameworks are available to use with that language or not.

_**Python**_ satisfies those conditions well. Considering those , other language ecosystems are not even closer to _**Python**_. 

But admit it or not , truth is
> **A programmer spends 90% of his time in Python while writing code for AI. On the other hand 99% of CPU time is spent on C/C++. Cause Python , its interpreter & most of the used Libraries are just abstraction over C/C++ under the hood.**