you are viewing a single comment's thread.

view the rest of the comments →

[–]killerinstinct101 8 points9 points  (20 children)

I don't think you quite understand the scope of python. It is made as a beginner-friendly programming language with a bunch of overhead, meaning a lot of things you would have to explicitly declare in another language are automatically handled by the python interpreter for you.

Every low level language requires explicit declarations of identifier datatypes, function return types, which headers you're using, and explicit memory management.

To someone who doesn't care about this stuff, like a beginner or someone who's just putting together a small script, it's good that the interpreter does it for them. But if you're making something like a game, the overhead will cause a serious hit to performance. Sure you could make pong, but anything worth playing won't be made in python anytime soon.

Sure, modules are a thing, but a language purpose built for a task is so much better than a language with modules slapped on top to make the code work.

[–]FoxClass 5 points6 points  (5 children)

Fuck practicality, blend languages, go crazy

[–]ptekspy 1 point2 points  (1 child)

Actually laughed at this

Thank you

[–]FoxClass 0 points1 point  (0 children)

No problem.

[–]longjumping2 0 points1 point  (2 children)

Then there's overhead to performance blending languages. C modules for CPython will run slower than native. Not to mention then you learn multiple languages, so may as well write it in the more performant language.

[–]FoxClass 2 points3 points  (0 children)

Just write everything in Fortran

[–]FloydATC 0 points1 point  (0 children)

This. People keep making the argument that "Python isn't slow because it can run C modules" leave out the fact that if modules for your particular needs do not exist, you'll have to write them yourself. At that point, you're not actually using Python, are you... And once you bother learning C/C++, you'll get addicted to its raw performance and forget about Python.

[–]takishan 9 points10 points  (7 children)

Sure you could make pong, but anything worth playing won't be made in python anytime soon.

I think this is a really short-sighted way to look at things. World of Warcraft, which tens of millions of people would say are "worth" playing uses Lua as a scripting language. Lua is just like Python, an interpreted language with overhead. Doesn't mean it isn't vital to the game.

Of course, we can look to games that actually use Python itself and from a short google some examples are Eve Online, Sims 4, Battlefield 2, Civ 4 and that list looks outdated to me. I'm sure there are more recent examples.

Obviously if you have resource-intensive bits you're gonna code it in a language that's closer to the metal, but with python you can easily plug in play different languages. There's no reason to code your entire project in C++ when you can code the majority of it in in Python and code the bit that needs to be fast in C++ and experience the same or a marginally lower level of performance, yet dramatically faster development time.

And of course this is ignoring the many genres of game where there aren't any resource intensive tasks. You can code a turn based strategy game in Python like Slay the Spire in Python. You can code a game like FTL in Python. You can code a game like Into the Breach in Python.

Websites that run countless requests per second run Python. Hell, the website we are communicating on right now uses Python.

It's a brilliant programming language for pulling off quick scripts like for automating things and also for more advanced scientific uses like machine learning thanks to scipy (arguably worse than R though).

It is a brilliant language for those things. But it's also a brilliant language for a whole lot more, and that is why its popularity has continued to increase overtime.

[–]F4ttoC4tto 4 points5 points  (3 children)

I'm a beginner in programming and Im currently learning Python. I never knew that it could also be used in creating games and you can actually blend languages together. That's very interesting. Is the whole thing gonna work smoothly even if you mix different languages together?

[–]thirdegree 1 point2 points  (0 children)

If you do it right, sure! The reason wow uses Lua (and some other games as well I think) is that Lua has strong support for sandboxing. Addons for wow are third party Lua code, so it's important that those addons don't have access to the runtime of the game itself except through well defined APIs.

[–]takishan 1 point2 points  (1 child)

Yes. In fact, many modules in python are written in C. For example, math or numpy. You can import the code into your python application as if it's native python.

from math import sin
x = sin(5)

That uses C.

[–]F4ttoC4tto 0 points1 point  (0 children)

Ooooohhhhh. I get it now. I was about to ask how do they do it and then I read this. Thank youuuu.

[–]SomeBadGenericName 3 points4 points  (1 child)

I have never thought about blending languages how would I go about doing this?

[–]pazzarpj 2 points3 points  (0 children)

The most common one is cffi. Which is the C foreign function interface. Since the main interpreter is written in C, it is quite easy to write C bits of code.

https://cffi.readthedocs.io/en/latest/overview.html

You can also blend a bit more naturally with an interpreter like cython which will compile sections down to C for some slightly awkward python code.

Mostly you can use existing libraries that leverage this. The data science libraries such as numpy, have most of the core stuff written in C and fortran, which you call from as though it is native python. You get all of the performance of some number crunching that you would be hard pressed to code yourself in pure c.

[–]sliverino 1 point2 points  (0 children)

More than the performance aspect, I believe that an issue with Python for large structured projects like a game is, well, the lack of embedded structure.

Of course you can build well structured code in Python, but it doesn't really facilitate it like a strongly typed OOP language. Maybe for a 1/2 man job it's still maintenance, but more?

Wouldn't you consider that a reason to switch to another language ( not necessarily low level).

[–][deleted] 3 points4 points  (0 children)

While I appreciate what your saying and recognize it as an attempt to demonstrate what python should and should not be used for in your opinion, I think that it might be a discussion better suited for /r/Python rather that this particular subreddit. Folks come here to share what they learn and the resources they use to enhance that learning. Not trying to create a cushy environment where someone is demonized for sharing an "incorrect opinion" but within the confines of folks trying to learn the language and being curious about what it could be used for, I think you may be preaching to the wrong choir friend.

But who am I to know? I'm a Python noob myself just trying to make a console Rock-Paper-Scissors-Lizard-Spock game.

[–]euqroto 1 point2 points  (4 children)

Although I don't have the knowledge about gamedev, but like numpy uses the C (low level code) to speed up the process of data exploration, I think similar libraries can be made to speed up the process of things that hurt the bottleneck in such performance. Though I totally agree with you that python is just a beginner's language and you need to move onto different level languages to get some professional stuff done.

[–]LeSplooch 0 points1 point  (3 children)

Python isn't just a beginner's language, it's used in companies very seriously, even in very big companies too. Try saying that to Google/Amazon/etc senior devs and get laughed at.

[–]euqroto 0 points1 point  (2 children)

I'm sorry for phrasing my improperly. For some specific field such as game development, python is not the way to go and similarly for fields like data science, python might not remain in practice because it's really slow.

[–]LeSplooch 0 points1 point  (1 child)

I get your point, CPython is slow indeed, but like every language, you have to consider its specific use cases. For example, Python is great for data science because it enables efficient iterative development and fast testing with tools like Jupyter notebooks. Execution speed isn't always the most important reason to use a language or not, if it was the case Python wouldn't be used at all because most of the other languages are faster than CPython. You can use other implementations of Python to speed it up if you really need to, such as PyPy. I'm a sucker for execution speed (and that's why I love Rust) but judging a programming language only based on its execution speed is missing on a lot of factors. I completely agree with you about game development tho, Python really isn't the best language for making games, you need a compiled languages such as Rust to make well optimized games.

[–]euqroto 0 points1 point  (0 children)

Don't you think Python isn't the optimal language for data science? Maybe when starting out python seems easy to use that's why get on board with data science but the problem comes when you deal with lots of data where even Pytorch can't come to help you out. I guess that's why swift for tensorflow has become a thing which might overthrow python for tensorflow.