Introduction of GDScript

GDScript is a dynamically typed and a high-level programming language. It is used to create content.  It is optimized and tightly integrated with Godot Engine, allowing great flexibility for content creation and integration.

History

In our early days, the engine used the Lua scripting language. Lua is fast, but creating bindings to any object-oriented system (by using fallbacks) was complicated and slow and took a significant amount of code. After some experiments with Python, it also proved difficult to embed.

The last third party scripting language that was used for shipped games was a squirrel, but it was dropped. At the point, it became evident that a custom scripting language could more optimally make use of Godot's particular architecture:

  • Godot embeds script in nodes.
  • Godot uses many built-in data types for 2D and 3D Script languages do not provide this and binding them in inefficient.
  • Godot uses threads for lifting and initializing data from the net or disk. Script interpreters for common languages are not friendly to this.
  • Godot already has a memory management model for resources; most script languages provide their own, which results in duplicate effort and bugs.
  • Binding code is messy and results in failure points, unexpected bugs, and generally low maintainability.

The result of the considerations is GDScript. The language and interpreter for GDScript ended up smaller than the binding code for Lua and squirrel, during the same functionality.

Example

Some people can look at the syntax, so here is a simple example of how GDScript looks.

If we have previous experience with statically typed languages such as C, C++, or C# but never used a dynamically typed one before, it is advised you read this tutorial:

Language

In the following, an overview is given to GDScript. Details, such as which methods are available to arrays or other objects, should be looked up in the linked class descriptions.

Identifiers

The identifiers that restrict itself to alphabetic characters (a to z and A to Z), digits (0 to 9), and _ qualifies as an identifier. Additionally, identifiers may not begin with a number. Identifiers are always case-sensitive (foo is different from FOO).


Next TopicKeywords




Latest Courses