Skip to content

Commit

Permalink
Add FAQ entry "Which programming language is fastest?"
Browse files Browse the repository at this point in the history
Compares the performance of C#, GDScript, and C++.

Co-Authored-By: Hugo Locurcio <[email protected]>
Co-Authored-By: Andre Sacilotto <[email protected]>
  • Loading branch information
3 people committed Nov 20, 2024
1 parent 76a8087 commit 6feb7b4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions about/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,38 @@ The main reasons for creating a custom scripting language for Godot were:

GDScript was designed to curtail the issues above, and more.

.. _doc_faq_which_programming_language_is_fastest:

Which programming language is fastest?
--------------------------------------

In most games, the *scripting language* itself is not the cause of performance
problems. Instead, performance is slowed by inefficient algorithms (which are
slow in all languages), by GPU performance, or by the common C++ engine code
like physics or navigation. All languages supported by Godot are fast enough for
general-purpose scripting. You should choose a language based on other factors,
like ease-of-use, familiarity, platform support, or language features.

In general, the performance of C# and GDScript is within the same order of
magnitude, and C++ is faster than both.

Comparing GDScript performance to C# is tricky, since C# can be faster in some
specific cases. The C# *language* itself tends to be faster than GDScript, which
means that C# can be faster in situations with few calls to Godot engine code.
However, C# can be slower than GDScript when making many Godot API calls, due
to the cost of *marshalling*. C#'s performance can also be brought down by garbage
collection which occurs at random and unpredictable moments. This can result in
stuttering issues in complex projects, and is not exclusive to Godot.

C++, using :ref:`GDExtension <doc_what_is_gdextension>`, will almost always be
faster than either C# or GDScript. However, C++ is less easy to use than C# or
GDScript, and is slower to develop with.

You can also use multiple languages within a single project, with
:ref:`cross-language scripting <doc_cross_language_scripting>`, or by using
GDExtension and scripting languages together. Be aware that doing so comes with
its own complications.

What 3D model formats does Godot support?
-----------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions tutorials/scripting/c_sharp/c_sharp_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ You can read more about this error on the `C# language reference <https://learn.
Performance of C# in Godot
--------------------------

.. seealso::

For a performance comparison of the languages Godot supports,
see :ref:`doc_faq_which_programming_language_is_fastest`.

Most properties of Godot C# objects that are based on ``GodotObject``
(e.g. any ``Node`` like ``Control`` or ``Node3D`` like ``Camera3D``) require native (interop) calls as they talk to
Godot's C++ core.
Expand Down

0 comments on commit 6feb7b4

Please sign in to comment.