IssueRaiser

Add structs in GDScript

### Describe the project you are working on Godot ### Describe the problem or limitation you are having in your project There are some cases where users run into limitations using Godot with GDScript that are not entirely obvious how to work around. I will proceed to list them. * Classes are fine in most cases, but if you need to a allocate a lot of them, they can be more inefficient. Classes are not lightweight in Godot. * Sometimes you want something between a class and a dictionary, with code completion to just throw game data written by hand. * When exposing some APIs to script (not many, but sometimes) we use a dictionary, which has not good doc nor code completion (as example, get_property_list), because creating just a class for that is a bit overkill (they use a lot more memory). * Sometimes, when working with dozens of thousands of objects (think Bullet hell, simulation, etc), as much as we can optimize the interpreter, the fact that memory is not flat makes this very very inefficient in GDScript because of the high amount of cache misses. Again, save for the third point, these are mostly performance issues related to GDScript that can't be just fixed with a faster interpreter. It needs a more efficient way to pack structures. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea of this proposal is that we can solve these following problems: * Add struct support to GDScript (this has some user demand, given

Posted by reduz on Jul 19, 2023, 1:31 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

support (Other)

Add structs in GDScript

reduzJul 19, 2023, 1:31 PM

### Describe the project you are working on Godot ### Describe the problem or limitation you are having in your project There are some cases where users run into limitations using Godot with GDScript that are not entirely obvious how to work around. I will proceed to list them. * Classes are fine in most cases, but if you need to a allocate a lot of them, they can be more inefficient. Classes are not lightweight in Godot. * Sometimes you want something between a class and a dictionary, with code completion to just throw game data written by hand. * When exposing some APIs to script (not many, but sometimes) we use a dictionary, which has not good doc nor code completion (as example, get_property_list), because creating just a class for that is a bit overkill (they use a lot more memory). * Sometimes, when working with dozens of thousands of objects (think Bullet hell, simulation, etc), as much as we can optimize the interpreter, the fact that memory is not flat makes this very very inefficient in GDScript because of the high amount of cache misses. Again, save for the third point, these are mostly performance issues related to GDScript that can't be just fixed with a faster interpreter. It needs a more efficient way to pack structures. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea of this proposal is that we can solve these following problems: * Add struct support to GDScript (this has some user demand, given

Comments (0)

No comments yet. Start the discussion.

Comment on this issue