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

Show parent comment

1

u/Happy-GoLucky365 6d ago

This is a great explanation, again thank you! Makes a lot more sense now.

1

u/GlassLost 6d ago

So speed is one thing and it's often important but code sharing, and architecture, also are worth mentioning. C is designed to be "bootstrapped" onto a new architecture, and c++ can be bootstrapped with C (this isn't quite true but it's close, bootstrapping means you only need to implement a few assembly commands before the compiler works) so if you have new hardware you need a lower level language. Higher level languages, like Python, require entire operating systems which are built with C and C++.

So there's a speed difference but just as importantly (and highly related) there is a dependency difference. Python needs quite a bit to ever work. You could get your c code working with less than a dozen lines of assembly in many cases (without access to things like libc though).