Is GDScript compiled or is it interpreted at runtime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wipeout85
:warning: Old Version Published before Godot 3 was released.

Having worked with Game Maker Studio in the past I know their engine has one of two ways to manage it’s scripting language known as Game Maker Language or GML Script. The first is to compile the GML script to bytecode and then interpret that at runtime, the other option being to compile the GML Script to C++ along with the runner which gives a big performance boost on native platforms. I was just wandering how the Godot engine handles it’s scripting language?

:bust_in_silhouette: Reply From: wipeout85

I’ve been informed that GDScript is compiled to byte code and interpreted at run-time. No native compilation is done.

:bust_in_silhouette: Reply From: Calinou

GDScript is not compiled to native binaries ahead of time (AOT). It is not compiled just-in-time (JIT) either. In short, it’s an interpreted language, similar to Python in how it is run.

However, exporting your game will, by default, convert your .gd scripts to .gdc bytecode (resulting in slightly faster loading of the game, in some cases). Exporting in release mode will give large performance improvements because of the lack of run-time checks that are only helpful for debugging. You can sometimes notice a performance improvement of 300% by exporting in release mode, in contrast to running from the editor.

How have you measured that (300%) improvement?

Bojidar Marinov | 2016-03-07 12:28

Since it is runtime interpreted code, are there things we can do in the gdscript files themselves (like minification) that would help the tokenizer to run faster? Things like short variable names, removing spaces etc?

Judd Gledhill | 2018-03-02 15:21