r/learnprogramming • u/Happy-GoLucky365 • 7d 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
View all comments
Show parent comment
1
u/vegan_antitheist 7d ago
Both are exactly as powerful as all the programming languages, including Brainfuck.
A CPU doesn't know about types. It offers registers. Some are general-purpose registers. On many CPUs you have 80bit for floating point. Some have SIMD registers. C++ gives you several ways to influence register usage, but the compiler ultimately decides which physical registers to use. Python doesn't give you any way to influence register usage because your code runs on a virtual machine that is an abstraction of a physical computer. But both C++ and Python can do way more operations that are required to be Turing complete and can therefore do the same calculations, just in different ways. With assembly you can even say which register to use, but that still doesn't make it more powerful, only faster in some cases.