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

185 comments sorted by

View all comments

Show parent comment

77

u/vegan_antitheist 5d 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.

3

u/no_more_cat_pics_pls 11h ago

Python can't be used for kernal or OS programming and it's lack of strong typing and no memory management make it much more prone to bugs and slower. You need very specific languages for certain things. C can't be used for websites like HTML but you can't just say they are turning complete and equal

1

u/vegan_antitheist 8h ago

Again: Both are Turing complete. There's nothing one can do the other can't. It doesn't matter how much some people want to deny this. I wouldn't even need examples to prove this, but those examples exist:

C can be and probably still is used for html. CGI programs built in C weren't even that uncommon in the 1990s. Amazon was just one example of a website made with C.

Amazon's first engineers coded in a computer language called C and decided to store the website in an off-the-shelf database called Berkeley DB

Source: The Everything Store: Jeff Bezos and the Age of Amazon (Brad Stone, 2012)

PythonOS is described as:

A bare-metal operating system where CPython 3.14 is the kernel — not a program running on an OS, but the OS itself.

Source: https://github.com/jordanhubbard/pythonos

1

u/no_more_cat_pics_pls 1h ago

Cool, sure a bike and a mustang can also both technically get you to the same place. Why not, both have wheels and theres nothing one can do that the other cant right?

-36

u/mysteryihs 5d 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.

50

u/Talbertross 5d ago

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

16

u/EquipLordBritish 5d ago

Not only that, but it's also (pedantically) incorrect. You could write a python program that outputs a custom executable that is every bit as fast as C code. It would be very annoying to do and I doubt anyone would bother, but it could be done.

1

u/Moscato359 2d ago

That's not really the python hitting the target anymore though is it

It's python making an exe, not the exe being python

1

u/EquipLordBritish 1d ago

Seems like you could say something similar about compiled languages, since the compiler is what actually writes the program.

1

u/Moscato359 1d ago

I mean, sure, technically you can make a python compiler which compilers from python to ML, and then C to ML and say they're the same, but the python language isn't really built for that

Technically feasible, and practical are not the same

1

u/EquipLordBritish 1d ago

That's about what I said in my initial comment.

2

u/Moscato359 2d 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/Talbertross 2d ago

Nah, you're just pulling some "can God make a boulder so big even he can't lift it" bullshit

1

u/Moscato359 1d ago

Uhm... Needing to hit a frame rate target is a very common thing for game development 

1

u/vegan_antitheist 2d 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 1d 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

6

u/moratnz 5d ago

"The difference is performance"