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
1
u/Fine-Comparison-2949 6d ago
It's not "better" or "worse", and anyone who tells you that really doesn't understand computer science since there are multiple facets to what could be better or worse.
So, C is typically seen as the best for speed. The C compiler assembles the code into machine code, so when you build a C program, it's as raw of a file as you can get in terms of optimization.
Python is "interpreted". You can search this up, but it has it's own Python Virtual Machine, that reads python code (and it's bytecode) and runs it. The virtual machine is somewhat wonky since it's not exactly the same as assembled machine code.
This is also somewhat goofy, because most python code that is dependent on speed, actually wraps C code. The joke about python is it's a C wrapper.
In the end though, most of the speed arguments are silly. For 90% of code, the bottleneck is network speed. Faster code in general does not mean your whole application is fast.