Godot Version
4.3
Question
How is GDScript compiled into executable?
I mean does it compiled into C# / C++ or other intermediate language first? Or does Godot directly parse and compile GDScript into binaries?
4.3
How is GDScript compiled into executable?
I mean does it compiled into C# / C++ or other intermediate language first? Or does Godot directly parse and compile GDScript into binaries?
GDScript is interpreted. When exported you can opt to automatically convert all GDScripts to a intermediate and faster to load version, similar to compiling (more like compressing), but not to machine code. As of 4.3 I believe it is always interpreted, never compiled.
Hi
GDScript is tokenised which is a bit lower level than interpreted, sort of like byte code. Static typing will also make it quicker. Even C# is tokenised and then run through the .NET framework. You’d need to use C++ / C / Assembler for full compilation, though even C++ relies heavily on external libraries.
GDScript can be faster than C# especially when directly calling internal Godot functions while C# can be quicker at doing brute force non Godot data processing.
Personally I far prefer GDScript over C#, but if I could do exactly as I wished I’d be using assembler. In my option GDScript is easier to learn than C# and it is tightly integrated into the Godot Editor so no external editor is required. I like the inbuilt editor and there is enough flexibility to adjust the settings to suit your needs.
Each has their pro’s and cons. But in the end it is the distributable natively compiled Godot engine, that your GDScript or C# scripts run in, much the same as Unity, that is going to do all the work, regardless of scripting language chosen.
Kindly
Ryn
I guess it make sense when it is interpreted in development stage.
How about exporting? Are the scripts shipped in a compiled / byte code format?
You can chose to have them saved as plain text in the export, tokenised, compressed and or encrypted. Basic compilation if you wish to call it that, is done each time the script is loaded and parsed by the engine.
I add my own encryption to them as well so to be doubly sure…
Scripts are parsed, error checked, tokenised and objectised as a whole before execution, this is far beyond basic interpreted which evaluates each line as it runs. The same runtime server exists in the development engine and the distributable engine. Catching errors in calls to other scripts, especially variable/key names generally only happens at runtime though. Preloading scripts into other scripts, especially when defined as a class, can mitigate this even further.
Trig