Why  C/C++ is faster than Python

Let’s jump in

To see what makes C/C++  faster  over Python

First, C/C++ is a compiled language and Python is an interpreted language


The annoying thing with the hardware is that it won’t understand the source code which you have written on your computer screen

The barbaric hardware understands only machine language which is 0’s and 1’s

So to convert our source code to machine code we use either a compiled language or interpreted language

But why?

Compiled language[C/C++] is faster than interpreter language[Python]

Because compiled languages[C/C++] translate the source code in one short on the other hand interpreter language[Python] translate the source code line by line

As a result, the overhead of interpreting the code makes the interpreter language[Python] slower and inefficient for intensive tasks such as

  • Audio processing
  • Video processing
  • Signal processing
  • Baseband processing
  • Digital image processing
  • Speech signal processing
  • Adaptive signal processing
  • 3D computer games

So, to program the above task speed plays a key role in the computation, especially for real-time performance

Second, C/C++ is close to the hardware

But why?

Because expressions in C/C++  can be compiled effortlessly into machine code


Because some idioms in C/C++ match exactly to machine-level instruction such as

  • Address of
  • Pointers operators
  • Decrement operators
  • Auto increment

As a result, C/C++ speeds up the computation  

If Python is dumb and crooked language then why do we use?

In programming languages there is nothing called perfect language every language has its prons and cons

So, according to need at the moment on a particular task one language might be perfect other might not

Here’s an example

C/C++ has poor portability

But what is portability?

That the designers of different CPUs have created different machine languages for all of their kinds

Then what’s the problem?

The truth is the program created for an intel  i7 in your computer can’t be executed on ARMv8  CPU in your phone

Straightway, the programs written in high languages(Python, javascript) can be run across different platforms

Clear as mud?

Here’s another one

C/C++ has an evil concept called pointers

Python and java don’t have a concept called  pointers in them

Pretty effective right?

But why do you say pointers are evil?

Because pointers  error are difficult to find in code, another eye-opening thing about pointers is that not secure from the security point of view

A pointer is a thief that does all memory leakage

Java came on this because of the notorious pointer’s error in C/C++

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.