r/learnprogramming • u/Happy-GoLucky365 • 5d 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
67
Upvotes
View all comments
2
u/xarop_pa_toss 5d ago
C++ and Python focus on completely different things. They are built almost as opposite to each other as possible.
C++ is a compiled language and it gives you real control over the hardware to a very minute level. This is both very good because you can optimize a lot but also much harder to use for high-level things.
Python is interpreted instead of compiled and the way it works is a lot more abstracted with layers of things you can't see underneath that let you focus on a different set of things. By design it is very modular and you will more often than not find yourself importing all sorts of libraries a.k.a. modules to perform data analysis or whatever python people do.
The languages focus on completely different types of objectives. If I wanted to write a program that needs to fit in a small chip that controls some machine, I probably wouldn't write it in Python because I need to optimize memory a lot. At the same time, if I wanted to analyze some dataset and chart some graphs, I'd probably just import Pandas and Numpy into a Python program and be done with it.
Edit: if you're interested, Google about the time difference of a basic for loop in different languages and why the difference is so big.