DEV Community

loading...
Cover image for C++ vs Python

C++ vs Python

saiansulsblog profile image Konchada Sai Ansul Originally published at saiansul.hashnode.dev ・Updated on ・3 min read

Hello Guys, Welcome back to another post of Sai Ansul's Blog.
In this blog we are gonna find which programming language is better.

So let's start,

Firstly let us know what is programming?

Programming is the way we can make the computer perform various tasks.

What is programming language?

It is a formal language to perform various tasks, there are several protocols and algorithms to be followed.

Let us know the types of programming languages:

  • Procedural Programming Language.
  • Functional Programming Language.
  • Object-oriented Programming Language.
  • Scripting Programming Language.
  • Logic Programming Language.

Some names of programming language are:

  • C++ Language.
  • C Language.
  • Pascal Language.
  • Python Language.
  • Java Language.
  • Perl Language
  • Lisp Language

So, now lets us know something about both the programming language:

C++

White Photo Gaming YouTube Thumbnail.png
It is programming language used for building high level programmed applications, developed by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". C++ supports different ways of programming like: object-oriented, functional, procedural and more.

Python

image.png
It is a programming language, it's object oriented, it's a interpreter language which is easy to learn. This can be used for software and web development also for data science.

Now let us know some of the of the difference between two programming language

C++ Python
It is statically typed It is dynamically typed
No scope as an backend developer Good option for backend developer
Need to write a lot of lines of code Less lines of codes required
It is pre; compiled It uses interpreter
Looks messy but manageable as compared to python It is easy since its object-oriented and simpler to use
C++ is faster than python Python is slower because it uses interpreter, it also determines on the type of data while running
It doesn't support garbage collection It supports garbage collection
TIOBE rating is 4 TIOBE rating is 3
Variables are limited within loops Variables are also accessible outside loops
Rapid Prototyping not possible because of larger code size Rapid Prototyping is possible because of the small size of the code
Not easy in contrast to Python because of its complex syntax. Program is easier to type

These were some of the differences between these 2 programming language.

Now let us know some advantage & disadvantages of Python & C++

image.png

Advantages of Python

  • Its portable
  • Its free and open sourced
  • Easy to use and fast to develop language
  • It has all the libraries that each requires

Disadvantage of Python

  • Speed is slower than C++
  • There are sometimes runtime errors
  • Its not a good choice for mobile development
  • Its used for functional programming
  • Its not a good choice for memory intensive tasks

Advantages of C++

  • It is also portable
  • Object oriented
  • Low-level Manipulation
  • Memory Management

Disadvantages of C++

  • It does not have any security feature
  • It can't support garbage collection
  • Difficult to debug while used for web applications
  • It becomes complex while in a very big and high level programming

So, since we have covered what is python & C++, its difference and its advantages and disadvantages.

Now lets proceed towards the conclusion

So, if you have read this, you might have a clear idea about which programming language is better and which one you should use.
Python is better beginners because of its easy code and syntax, its a good for who want to choose their career in backend web development.
Python is also leading language for data analytics and machine learning .
But, if you want to develop applications or software then C++ is a good programming language to go for.

Now, at the end you have to decide for what purpose which one you have to choose.

Discussion (19)

pic
Editor guide
Collapse
hanpari profile image
Pavel Morava • Edited

The last time I checked, OOP was implemented in C++. In fact, programming with objects was one of main differences between C and C++.

Furthermore, being static typed doesn't mean that Runtime errors do not happen in C++.

Python is specification of the language, the implemention you were talking about is called CPython.

Finally, I am quite sure you would find plenty of C++ backend applications.

Majority of high performant server backend applications are probably written in C++. Just ask Google.

Hope it helps.

Collapse
saiansulsblog profile image
Konchada Sai Ansul Author • Edited

Thank you for checking my article. I'm glad that you took the time to point that out in such an elegant manner.

It was helpful

Collapse
james_palermo_bc208e463e4 profile image
James Palermo

Concerning your point that Python doing functional programming as a "con," I'm a bit confused. Did you mean imperative? It is easy to write overly imperative Python, which is a good point, but I'm confused what you mean with functional.

Collapse
daniel1404 profile image
Daniel Diaz

Nice article, but I think you should rename the article from

C++ vs Python
to
Comparison between Python and C++

That's because the title seems you are confronting these two languages and as we know there isn't a better language than other 😁

Collapse
saiansulsblog profile image
Konchada Sai Ansul Author

Thanks for suggesting,
I'll keep this in mind in the next comparison article πŸ˜„

Collapse
whippingdot profile image
Sanjaay R.

Very good article. The main reason I am happy is because you are not a python nerd and you are not biased!

You also didn't choose for us, and let us choose, thought that can be frustrating for some people...

Collapse
saiansulsblog profile image
Konchada Sai Ansul Author

Thanks a lot!

I'm glad you found this interesting πŸ˜„

Collapse
james_palermo_bc208e463e4 profile image
James Palermo

Is this an April Fools article that got scheduled to post incorrectly… ?

Collapse
hanpari profile image
Pavel Morava

If you are referring to its factual incorrectness, I guess it is called learning by writing.

Most articles here are like this.

Anyway, the best way how to react is to point out problems in the article. Your comment is far from constructive.

Collapse
james_palermo_bc208e463e4 profile image
James Palermo

I apologize, I literally thought it was an amusing and clever way to name the article and then leave some things out to upset C++ folks. The author didn't seem stupid or wrong to me, just like he was having some good natured fun.

Thread Thread
hanpari profile image
Pavel Morava

Oh, he is incorrect in many things. I pointed out a few of them in my first comment.

Being wrong is not the same as being stupid, anyway.

Thread Thread
james_palermo_bc208e463e4 profile image
James Palermo

I agree entirely.

Collapse
technoglot profile image
Amelia Vieira Rosado

Hmm, what makes you think so? πŸ€”

Collapse
james_palermo_bc208e463e4 profile image
James Palermo

It left out a lot of stuff in the pros and cons that made me assume it was on purpose to tease the C++ fanboys.

Collapse
biffbaff64 profile image
Richard Ikin

No scope for backend development with C++???

Collapse
saiansulsblog profile image
Konchada Sai Ansul Author

There are scopes, but python has much more scopes compared to C++.

Collapse
biffbaff64 profile image
Richard Ikin

Oh, I know, but C++ is a language that should never be underestimated.

Collapse
cmuralisree profile image
Chittoji Murali Sree Krishna

Nice info, good work πŸ‘

Collapse
saiansulsblog profile image
Konchada Sai Ansul Author

Thank you so much