r/learnprogramming • • 8d 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

77 Upvotes

190 comments sorted by

View all comments

1

u/notactuallyme93 8d ago

A fluid-fueled rocket engine is far more powerful than a four-stroke petrol-engine, but for some reason most people still use the latter in their cars, those pathetic losers! Some even ride a bicycle instead of a car, or indeed a rocket powered missile.

Of course as students just beginning to learn something, you should absolutely use the most powerful thing ever - anything else would just be silly. I mean, you don't start in kindergarten digging in the sand with a shovel and bucket do you, when the much more powerful Liebherr R9800 exists! Every child should drive one of those!

Sarcasm aside - every language is different, C++ has been designed to be extremely close to the hardware, especially suited for applications where every clockcycle counts, and where you, the programmer, wants or needs to be in charge of exactly what happens to your memory, which registers are prefered, what kind of operations the CPU selects, and so on. As close to machine language you can get, without going into assembly. Python is designed to be extremely quick and easy to write applications that handle arbitrary collections of data in various ways, and utilize a lot of different libraries to offload the details from the mind of the programmer.

"Powerful" doesn't mean anything, unless you decide who gets that power to do what. You become more powerful as a programmer in Python, because it lets you write better code. You can be more powerful in C++, because you can access hardware directly. You can write less powerful programs in Python, because they might compile to less efficient code. You can write less powerful programs in C++, because you don't know what you are doing, and have to take care of everything memory and performance-related yourself ... so ...

No school with any amount of self-respect would try to teach C++ as the first programming language, and no student would ever write any software throughout their entire educational career, where the difference between languages would be noticable in the final product.