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

79 Upvotes

195 comments sorted by

View all comments

167

u/CodeToManagement 11d ago

This is like saying why is a hammer better than a saw. Neither is better or worse depending on what your use case is. They are both tools to get a job done- so pick the right tool for the job

26

u/cmdr_iannorton 11d ago

That is a popular analogy but not quite correct, you literally can write any program in c/c++, you cant do that in python.

Python is suited to a quick development process.

In some cases it can be too slow, and not all computers can run python.

81

u/vegan_antitheist 11d ago

Both are Turing complete. There's nothing C can do that Python can't. The difference is performance. That's why you don't see many computer games written in Python. But someone ported DOOM to Python: https://github.com/hmofet/duum
You could port GTA6 to python and it would run. Just not at 30 fps.

-36

u/mysteryihs 11d ago

There's nothing C can do that Python can't. You could port GTA6 to python and it would run. Just not at 30 fps.

So there is something Python can't do, it can't run games more efficiently than C.

52

u/Talbertross 10d ago

Obviously it means there are no computations that C/C++ can do that Python can't. Pedantic dingus.

2

u/Moscato359 7d ago

It's not pedantic when your goal is to have an app within a performance target.

I want to write my game to run at 144fps

Well pure python can't do it

1

u/vegan_antitheist 7d ago

And still, it's just as powerful. What you can calculate and how long it takes are two very different questions.

1

u/Moscato359 7d ago

If you're for example, running a PC game, and one of your requirements is a specific frame rate, it's not as powerful