-
This repository appears to be very clean and promising. Upon examining the examples, I noticed that every Godot function, whether inherited or called, requires a Context as a parameter. While this isn’t a deal-breaker, it does seem redundant. I looked into the internal code and found a comment explaining the necessity of providing a unique Godot context for each call. However, I’m wondering why this isn’t the case with other language extensions like C++ and Rust. Is this a safety enhancement implemented on top of Godot, or is there some performance consideration involved? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
This isn't the case for C++ because memory needs to be managed by the developer, this isn't the case for Rust, because the language has memory ownership semantics that provide memory safety. This isn't the case for the official Godot C# bindings, because in C#, Godot memory can be freed by the C# garbage collector, as presumably, C# has reasonable mechanisms to do this when interfacing with C. Go doesn't have any language-supported (efficient and reliable) way to manage foreign memory (ie. Godot objects and values) via the garbage collector. It has finalizers, but these are not really meant to be used for lots of small-short lived references.
It is primarily used to ensure memory safety, it shouldn't be possible to double free, use-after-free or to leak memory within a function when using the
Thanks for the feedback, the primary goals of this project are safety and performance, this does mean some aspects of working with Go+Godot will be a bit awkward and low-level. If you are looking to work with Go + Godot using more idiomatic types, |
Beta Was this translation helpful? Give feedback.
-
@ShirenY this has been completely resolved now, no more Context! |
Beta Was this translation helpful? Give feedback.
@ShirenY this has been completely resolved now, no more Context!
See #67