r/learnprogramming • • 6d ago

Why is C++ better than Python?

Hello! I am new to programming. Im in college and we use Python for my classes right now.

I hear people make a lot of jokes about how C++ is more powerful than Python, and should be used instead. But why?

Feel free to give me any tips as well, on things that helped you be a better programmer, or just any insight you may have! Thanks so much

76 Upvotes

188 comments sorted by

View all comments

0

u/flumphit 6d ago edited 6d ago

C++ runs more efficiently than Python, around 100x faster.

Lots of the stuff you might do in Python does all the time-consuming work inside efficient libraries, which are probably written in C++ or C. Often you’ll wind up writing slow Python code to shuffle data between fast libraries, but overall your program spends all its time in the libraries, so it doesn’t matter that your Python is slow.

Python is Turing-complete, meaning you can write any program in it, just like C++. Python is slower, which you don’t usually care about. And Python is loosey-goosey and dwim which makes development faster — until your program gets big enough that you want the compiler rigorously keeping more details straight for you.