6 ms·
You really want a higher performance language than python for things like games. C# is a decent compromise, since you can do some tricks to avoid garbage collec
by barbariangrunge 3y ago
You really want a higher performance language than python for things like games. C# is a decent compromise, since you can do some tricks to avoid garbage collection, but python? It'd have to be a situation like sklearn and numpy where all the actual functionality is implemented in c/c++ and you're just using it as a glue language to coordinate those pieces, and at that point it's basically c/c++ already with python acting like unreal blueprints or something
Even if you managed a good framerate, would you get good uniform frame pacing?
It's not that it's impossible, I'm just skeptical
- lewispollard 3y ago> It'd have to be a situation like sklearn and numpy where all the actual functionality is implemented in c/c++ and you're just using it as a glue language to coordinate those pieces You've just described most game engines that use a "scripting language" - even those that use C# do it this way (barring maybe one exception I can think of)
- ensignavenger 3y agoSee also, Panda3D https://www.panda3d.org/ https://www.panda3d.org/
- barbariangrunge 3y agoDo you really want your designers to have to learn python though? If they're learning python, they may as well learn c# or c++ and go all the way into programming. Unless it's a visual novel I guess, where renpy is popular
- raincole 3y ago> If they're learning python, they may as well learn c# or c++ No? See: data scientists. And really any scientist whose daily job involves statistics.
- crustaceansoup 3y agoWhy does it have to be used by designers? Programmers can get benefit from the faster iteration time and level of abstraction from the engine code. It's also really nice for onboarding juniors. My first game dev job was as a junior gameplay programmer at EA working mostly in Lua on top of a C++ engine.
- raytopia 3y agoA lot of people who are designers and artists already know Python because of its heavy use in 3D pipelines. Honestly I'd argue it makes more sense to also let them do scripting in something they already know.
- reactordev 3y ago“even those that use C# do it this way” The only thing we do is P/Invoke native draw calls. OpenGL, DirectX, Vulkan, they expose C functions that we call with pinned memory. That’s about where it stops. Everything else is in C#. Events, actions, game logic, networking, file system, all in C#.
- lewispollard 3y agoWho's "we" in this case?
- reactordev 3y agoAuthors of C# game engines
- lewispollard 3y agoI can think of MonoGame and Stride as examples/exceptions, though I suppose there are more out there, including peoples' own engines. Most popular engines that expose a C# interface officially or unofficially take the other route. But I grant you that the oft-given reason for this - performance - isn't impossible to achieve with pure C#, it just takes a lot more skill and knowledge, and that performance via native calls to a C++ engine aren't always more performant anyway due to marshalling.
- westurner 3y agohttps://www.reddit.com/r/O3DE/comments/rdvxhx/why_python/ https://www.reddit.com/r/O3DE/comments/rdvxhx/why_python/ : > Python is used for scripting the editor only, not in-game behaviors. > For implementing entity behaviors the only out of box ways are C++, ScriptCanvas (visual scripting) or Lua. Python is currently not available for implementing game logic. C++, Lua, and Python all implement CFFI (C Foreign Function Interface) for remote function and method calls. "Using CFFI for embedding" https://cffi.readthedocs.io/en/latest/embedding.html https://cffi.readthedocs.io/en/latest/embedding.html : > You can use CFFI to generate C code which exports the API of your choice to any C application that wants to link with this C code. This API, which you define yourself, ends up as the API of a .so/.dll/.dylib library—or you can statically link it within a larger application. Apache Arrow already supports C, C++, Python, Rust, Go and has C GLib support Lua: https://github.com/apache/arrow/tree/main/c_glib/example/lua https://github.com/apache/arrow/tree/main/c_glib/example/lua : > Arrow Lua example: All example codes use LGI to use Arrow GLib based bindings pyarrow.from_numpy_dtype: https://arrow.apache.org/docs/python/generated/pyarrow.from_numpy_dtype.html https://arrow.apache.org/docs/python/generated/pyarrow.from_... https://github.com/scikit-learn-contrib/sklearn-pandas https://github.com/scikit-learn-contrib/sklearn-pandas : > Sklearn-pandas: This module provides a bridge between Scikit-Learn's machine learning methods and pandas-style Data Frames. In particular, it provides a way to map DataFrame columns to transformations, which are later recombined into features. Pandas docs > PyArrow > I/O https://pandas.pydata.org/docs/user_guide/pyarrow.html#i-o-reading https://pandas.pydata.org/docs/user_guide/pyarrow.html#i-o-r... : > By default, these functions and all other IO reader functions return NumPy-backed data. These readers can return PyArrow-backed data by specifying the parameter dtype_backend="pyarrow" > [...] Several non-IO reader functions can also use the dtype_backend argument to return PyArrow-backed data including: to_numeric() , DataFrame.convert_dtypes() , Series.convert_dtypes() df = pandas.read_csv(".csv", dtype_backend="pyarrow") sx = pandas.Series([1.0,2.0], dtype="float32[pyarrow]")
- andybak 3y agoIn Unity you often use C# for some fairly performance critical stuff. That's one of the reasons they bothered with the Burst compiler, the Jobs system and native arrays.
- lewispollard 3y agoWell, Unity is a good example of this, because most of their techniques involve transforming your C# code or assembly into something else that doesn't run on the .NET runtime, or else having you structure it so that it can be offloaded - directly into C++ code in IL2CPP, or using LLVM to turn the IL bytecode into machine code with Burst. I don't know much about the Jobs/DOTS stuff but I assume the restrictions around it and how you use it are either due to it being based on a strict call-out to C++ code, or else some underlying "unsafe" C# code that Unity is managing safety around via structure - from a little reading it sounds like probably both.
- cuddlyogre 3y agoLook at it from the point of view of someone that wants to make something without having to devote considerable time to learning a language as complicated as c++ or c# relative to python. Everyone starts somewhere.
- __loam 3y agoGodot has gdscript which is actually written with the use case of game scripting in mind. It's a much better option for this application.
- city41 3y agoAnd gdscript is very python-like
- krapp 3y agoNot really, beyond using significant whitespace.
- cuddlyogre 3y agoBut it's not python. What if the user wants to write in python?
- __loam 3y agoThey should reconsider
- ensignavenger 3y ago>> It'd have to be a situation like sklearn and numpy where all the actual functionality is implemented in c/c++ and you're just using it as a glue language It sounds like this engine is not implemented in 100% python. See also Panda3D https://www.panda3d.org/ https://www.panda3d.org/, which was used in commercial games back in the day, and is exactly what you are describing!
- raytopia 3y agoPanda3D while not perfect is awesome! Wish more people knew about it.
- ensignavenger 3y agoI always really liked the Panda3D Python API.
- dbrueck 3y ago> glue language ... at that point it's basically c/c++ already with python acting like unreal blueprints or something Yeah, I mean that's pretty much the main role of a game engine's scripting language - gluing the lower level pieces together in the game-specific way. We use Python for all of our runtime application logic in UnrealEngine and performance is far beyond good enough and significantly faster than blueprints.
- raytopia 3y agoIDK Python was used by Disney with two of their mmos in the early to late 2000s and those were targeted towards super low end family computers and they didn't seem to have issues with performance. Python's slowness seems to be overstated.
- m463 3y agoIt says "backend in c++". the game logic is usually not a performance bottleneck.
- cmdrk 3y agoIt depends on what you're doing. Computers are fast! Like, really fast! And not every game is an AAA, fully 3D title with ray tracing and etc etc. Games are such a broad topic and I believe people can absolutely make games in Python without spending all of their time fighting GIL monsters and garbage collectors.
- qwery 3y agoIf you're talking about people doing things because they want to, then yes, go for it, have fun. But performance does matter. The technical state of the art (ray tracing etc) is largely irrelevant. If you make a game with cutting-edge technical features, the performance of it will be judged accordingly. If a game with a modest feature set demands resources in excess of its apparent need, it's wasting those resources. In other words, a washing machine that uses more water than others is a worse washing machine. To be clear, this isn't to say that you're wrong. Everyone can continue doing what they're doing -- really.
- deleted 3y ago[deleted]