0 votes

Hey folks, im trying to find game engine in order to TRY create my first game. Im not new to programming but im new to game programming.

Before i ask actual question i must say that i love c++ for OOP, being statically and strongly typed language, structures (custom types), function overloading, pointers and dynamic memory allocation (being able to manage memory hence optimize the shit out of my software). But for me (personal opinion) c++ "lacks" easy events and timers. When i say these i mainly compare it to C#. And timers and events are one of the key elements in creating games so i guess i have to find some compromise. Being able to use c# with godot, and c# having most of the things i like compared to gdscript i guess c# is better option for me.

My questions:
c# vs gdscript performance? Overhead and memory usage as im limited with that.
What do i lose and gain by using C# with godot?
Is it possible to expose C# methods as API to gdscript? (i was thinking about using gdscript to support modding)

asked Oct 26, 2018 in Engine by NegativeIQ (12 points)

1 Answer

+2 votes

GDScript is slower than C# but way better integrated because it was made from scratch for Godot, it's here from the beginning and interfaces more directly with the engine (i.e no marshalling, no extra GC and engine features like signals and pool arrays have a 1:1 match). It's also more stable due to this.

C# is faster (as far as Mono is) but was added more recently. It is less integrated (less integrable I even dare say) because engine features can't always map 1:1 with the language and its standard library, and might have some bugs. It also adds significant weight to the engine (a few megabytes) so it ships as an alternate engine version. Also, although C# is quite fast, it has an extra GC on top of Godot's memory management, so if you care about memory you should care about GC kicks too.

Both languages can communicate using the Godot introspection layer. For example, any language that can call a method can at least do so with object.Call("MethodName", argument) for example.

About modding:
You can load GDScript code from anywhere you want by creating scripts manually (GDScript.new(), assign source code and call reload), so you can use GDScript for modding to some extent. However, as it was said many times, the Godot scripting layer was not thought for sandboxing. That means any script you compile this way has the same access rights as your game code, and can access all Godot features including filesystem, network etc. so mods have to be entirely trusted if you go that way.

answered Oct 26, 2018 by Zylann (26,157 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.