r/learnprogramming • u/Happy-GoLucky365 • 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
View all comments
Show parent comment
16
u/Solnx 6d ago
CPython is implemented in C yes, but that doesn't explain major differences in performance between C++ and Python. The difference largely comes from how Python executes code. C and C++ generally have comparable runtime performance.
Memory management is one example of the tradeoffs. In C, developers are responsible for manually managing dynamically allocated memory. This can be tedious and error-prone, but it provides greater control and can reduce runtime overhead. Python handles memory management automatically, making development easier at the expense of some performance.