n
nschue
posted to: Coding the State

Static typing

By default static typing is turned off for auto code completion, is static typing a best practice in gdscript?

  • n
    nschue replied

    After some research, it looks like starting in Godot 4 static typing will provide a performance improvement in many instances.

    https://godotengine.org/article/gdscript-progress-report-typed-instructions

  • Nathan Lovato replied

    We explain it in the Learn GDScript app, in the last lesson: gdquest.github.io/learn-gdscript/

    People tend to focus their attention on performance improvement, but it's the least important benefit. When coding with static typing, the computer catches many more errors early for you. It prevents bugs and helps to fix issues much faster than with dynamic code. It also makes your code more explicit and thus easier to understand or use.

    And that for yourself too, because as you will see when making complete games, we quickly forget about how we coded this or that thing.

    In the course, we use it constantly for training purposes, but then when you make your games, you can decide to write foundational code with static types and use dynamic in other instances.