tayloraswift / godot-swift

swift language support for the godot game engine
116 stars 5 forks source link

Thanks for the lib! Pasted my question from reddit just in case here is a better place #1

Closed hyouuu closed 3 years ago

hyouuu commented 3 years ago

Thanks! Is delegate _:Godot.Unmanaged.Spatial a new syntax you introduced? I've never seen this in Swift. Also it would be great to have some performance test - there are people making Kotlin plugin and I think initially one approach generated really bad performance, but theoretically using native binding could even outperform GDScript. I'm really occupied at the moment so couldn't help much. Looking forward to it getting mature and ready for Godot 4!

tayloraswift commented 3 years ago

i already responded on reddit, but basically the underscore means that the delegate variable is not used in the body of the init(delegate:) initializer in the example code. In a more sophisticated project, you would probably need to access the delegate.

The Godot.Unmanaged.Spatial type is the Godot Swift analogue of the Godot::Spatial delegate in GDScript.

hyouuu commented 3 years ago

Thanks! Learned something new today ;) I thought it might have meant that but I guess there's never a real use case for it?

Regarding performance, it seems for Kotlin it is the language itself's limit (https://github.com/utopia-rise/godot-kotlin-native), so probably won't affect this project. Nevertheless it would be great to have some benchmark at some point - apparently on heavy computation within the script, it should outperform GDScript :)

tayloraswift commented 3 years ago

i haven’t done any rigorous benchmarking, but Godot Swift uses as minimal- and low-level abstractions as possible, so there should not be a lot of interop overhead at all. Swift is a compiled language and on average achieves performance in between that of C and C++, so computation in a Swift nativescript is almost certainly faster than in GDScript, most likely by a large margin.

hyouuu commented 3 years ago

Awesome I'll close this - keep the great work up!