Should I choose GDScript or C#

Hello everyone. I have recemtly decided to start using Godot for my game projects.
I have about 18 years of experience coding in C# and thought that I could continue using this language while developing with Godot. Through reading through docs and forum post, its seems to be that C# can be some what limited to using GDScript (Profiller doesn’t work, must recompile entire project for code changes to take effect).

I was wondering what you would recommend using in Godot?
Is it worth learning GDScript for some additional functionality?
Should I stick with my trained knowledge of C# despite less features?
What are some pros and cons of using one over the other?

Thanks for taking the time to give me some feedback.

1 Like

I have thought a lot regarding what to chose, and the answer is, whatever you like. If you do not have experience in game dev, I would recommend to start with gds to just get familiar with the env., functions, nodes etc. and when you feel comfortable using Godot, start switching to C#. gds will be faster, as it is built on top of C++, and its basically the Godot’s main language, but it does not mean that C# is bad uisng in Godot. Start with gds, get familiar, and then switch to C#.

2 Likes

This discussion has been popping up with increasing frequency. You can look up the prior discussions if you’re interested in people’s opinions.

2 Likes

When I first picked up Godot, I started with C# as I was already familiar with the language. I then later gave GDScript a try to see what it’s like. Personally I prefer GDScript. The engine integration is really handy, no recompiling every time, being able to change code mid testing without restarting. The faster workflow is what hooked me.

Then again, C# has advantages too. The biggest thing I miss in GDScript are interfaces. With neither multiple inheritance nor interfaces, it can be hard to write code that is flexible and avoids redundance. Not to say it’s impossible though. Access modifiers and certain data types like uint or smaller ints like a byte are also a C# only thing. Also if you wanna use any already existing C# libraries you have to use C# of course.

It’s also important to consider what kind of project you would like to make. I am not sure if Web export with C# is a thing yet. When I started it wasn’t. You can always mix and match C# and GDScript within the same project too. However, C# limitations are applied.

So yeah. For your first project it probably really doesn’t matter what you use (unless you need Web export). I would probably recommend starting with C# to focus on learning Godot and then trying out GDScript later. Just so you don’t have to learn EVERYTHING new at once. That is what frustrated me a lot at first. And once you tried out both, you can pick your favorite. :>

@olekmandruk, is that true? I was under the impression that C# was the faster running code. At least I heard people say that GDScript in comparison is slower. But maybe that’s just certain people being louder than others. I don’t have any data to back up either side.

3 Likes

Yes, for calling inner functions gds is faster, but for doing custom calculation C# will be faster. On YouTube I found a video, where it was compared which is faster and when.
Replied again as not sure If I hit the reply button

2 Likes

I think you should at least have a look at gdscript and then decide what you prefer. It’s easy to learn with your experience and you should quickly see whether you like it or not.

And in other similiar posts here or on reddit there should be mentioned all the pros and cons people have.

In my opinion, everyone should develop in GDScript, and then for things where it makes sense, refactor into C#. GDScript is always going to be faster accessing godot internals.

C# is faster at some things but not all. Collections, and Collection.Generic, C# is demonstrated to be as much as 20x faster…BUT, unless you have very large data sets doing lots and lots of read/write/sorting operations (basically a data science project) you won’t realize any real benefit from that.

System.IO is also measurably faster if your network game is an MMO or high CCU high speed FPS, then you might want to consider building your network class in C#, but otherwise…you won’t see any real performance gains.

The gain in productivity speed of using GDScript in most cases is overwhelmingly more beneficial than the incremental performance gains you are going to see using C# for most use cases.

At the very least become versed in it, prototype in GDScript and refactor in C# If it makes sense.

2 Likes

Don’t really agree, C# is more adult language. you get some benefits from coding in it. and you can always can refactor to GDScript for your optimization if needed :slight_smile: .
For heavy duty still can program C++ and put there assembler code inside.

When you know how program C# in Godot you will be able program GDscript with no extra effort.

1 Like

Things to keep in mind:

  • you can’t use GDScript classes in C# but vice versa. meaning that you won’t be able to use some plugins there
  • you want to export a web app? No C# for you!

I would use C# if I had an existing codebase or need a specific library. Since you’re a experience programmer, skill won’t be a factor with GDScript.

No offense but I have to disagree here because of the thing i mentioned earlier.

GDScript is very much built in a way that best supports component based systems as it has the limitation of no interfaces nor multiple inheritance, as well as Godot itself only allowing one script per node. If you are not used to that, for example because you previously worked with Unity, this will be something you will need to learn in addition.

While in C# you would do something like

public partial class Player : CharacterBody2D, IHurtable, IInteractable, ILootable

in GDScript you would need to make a separate HealthComponent, an InteractComponent and a LootComponent and attach them as node children. Then also manage how these components communicate with each other as the functionality has been spread out more and so on.

If you have worked with component based systems in C# before then it’s fine, but if you haven’t, it is something you should ideally know when working with GDScript. Because in C# you have the choice, while in GDScript, you are more or less forced.

1 Like

Maybe that’s just my fetish, but I would try to avoid any class declaration like that in Godot.
We are using an engine where nodes can be composed freely. Inheritance makes composing very hard since you can’t just plug-in new behavior without introducing a new layer of abstraction.

A component based approach forces you encapsulate behavior by default.
Having a HealthComponent that works in a general way is much easier to reuse. It’s also more understandable than hiding it in different implementations.

923w96

Have a nice one :coffee:

3 Likes

Of course is not gonna be 1:1. and this what i mean with C# more adult.
In C# you use Interfaces in GDScript you will use has_method. :+1:

That’s not my point.
Of course you use inheritance. To extend a node you need to inherit a Node.

You shouldn’t design features based on inheritance if it can be solved otherwise.
That’s not a personal opinion, rather a common technique.

Generally I’m arguing from the point of a professional. For me it’s more important to have a readable and understandable project that it’s easy to get into as a new dev.
For example: a large inheritance tree is a first slap in the face of new dev who should implement a certain feature for a new entity. You need to encapsulate this behaviour first and make it reusable.

You’re right but being restricted to Variants is not a good deal imo.
When I get a pull request with a comment like “it is messy but it works” in a fundamental component, it’s rejected with :face_with_raised_eyebrow:

I’ll leave it at that since OP probably knows the ins and outs of inheritance.
Would be nice to know what OP decided to use and why :coffee:

There is no such thing as an adult language, a programming language is just a tool, to put into work your abstract knowledge of programming. Every language is unique and has a goal for which it was created in a way it is. One need to learn computer science, engineering etc. The programming language is just a brush which you use to paint

1 Like

It is more adult for me :slight_smile:
obraz
C# is 23 year old and still in active development

1 Like

I was wondering what you would recommend using in Godot?
Is it worth learning GDScript for some additional functionality?
Should I stick with my trained knowledge of C# despite less features?
What are some pros and cons of using one over the other?

I have a similar amount of programming experience, though not primarily with C#. I’ve worked a little bit with C# before starting to use Godot, but I’ve worked extensively with a very broad range of languages. Assembly languages, C and C++, Bash, Python, Lua, JavaScript and TypeScript, and a lot more. Now, I’ve been working with Godot for the better part of a year, on-and-off but more on than off, in both GDScript and C#. There’s a whole impassioned debate happening in this post but I will attempt to answer the question more impartially and more exhaustively than most others will be able to do.

GDScript has one strength: So far, it has received closer attention to integrate it cleanly with the editor and engine than any other language.

GDScript has numerous weaknesses.

GDScript has no functional static typing system. There are type annotations and there is some static analysis functionality to check type correctness, but it is so incomplete and dysfunctional that you almost might as well not bother. Not having static types is not a big deal for smaller projects. If you are working on something more ambitious, especially if you are working in a team with others, the lack of mature static analysis tools will be extremely painful. (I know this from professional experience. It’s the same reason why TypeScript is increasingly replacing JavaScript in professional settings.)

GDScript is fundamentally object-oriented, and yet its tools for OOP are very incomplete. There are no generics and no interfaces. There is also no multiple inheritance. It’s all the drawbacks of Python’s convoluted, footgun-prone duck-typed classes, but without the same benefits.

GDScript’s error handling tools are nearly nonexistent. There are no thrown or caught exceptions. Functions cannot return multiple values, nor tuples, not unless you want to allocate an untyped array for it. Functions cannot receive arguments by reference, and there is no equivalent to an out parameter as in C#. There are no Optional or Result types, and no particularly good options for defining your own. If you have a function that needs to be able to both return a result and indicate error/success, beyond just returning null on failure or such, then you have no good options. If you need to propagate an error up the call stack, you have no good options.

GDScript lacks basic tools for writing performant and efficient code. There are no user-defined packed or pass-by-value types (i.e. structs). There are no user-defined iterators, there are no generators, there is no GDScript equivalent to the C# IEnumerable interface, and in general if you are working with lists of things you are just going to be using fully in-memory arrays.

GDScript generally lacks basic usability and quality-of-life features. And amid all of this, there is not even a preprocessor to try to work around some of it, i.e. no defines and no macros. Not without brewing up your own preprocessor, which will have no editor integration and won’t work with Godot’s LSP.

GDScript has no package ecosystem. It has no easy way to integrate with packages written in any other language. Though there are addons out there you can use, there are a lot of usability issues with that and not a lot of people are publishing them. If you need something that isn’t a built-in part of the engine, then you are probably writing it yourself from scratch. This is not the case with C# for Godot, with which you can use any NuGet package.

(For me, though, the final straw that had me fully give up on GDScript was when I started having to restart the editor for it to wake up and stop reporting nonsense errors. I would add a new method or property in one file and then Godot believed the new method/property name was nonexistent when trying to refer to it in other files, until I restarted the editor. I am not sure what caused this. What I do know is that it fully wore away the last of my patience for GDScript, despite the editor integration benefits.)

Those who praise GDScript are those who don’t know what they’re missing out on, which is a lot. I would estimate that GDScript is at least ten more years from being the right option for serious projects, at the current pace of development.

Godot’s C# support does have some small gaps. The gap I’m most looking forward to seeing fixed is that documenting comments in C# on exported properties cannot be shown as tooltips in the editor’s inspector, as they can with GDScript. But overall C# will give you a far better experience with Godot than GDScript, and you can always mix in a little GDScript if you want to. The only exception would be if you are working on a project so small that GDScript’s issues might not catch up with you, or if you were inexperienced enough that a more robust and professional language like C# would feel more intimidating than helpful.

4 Likes

Yes, in my opinion you have even more features in C#.
When I came over from Unity to Godot last year, I was a bit shocked how many things can be done entirely in C# without the need for the actual engine. In Unity most things were hidden on the proprietary C++ side. In Godot you have the unmodified .NET runtime next to the engine itself.

I can’t compliment the Godot 4 developers enough for this decision, as this allows you to use everything from the .NET ecosystem. This also includes IDEs like VisualStudio and Rider and their profiling tools.

There also is the performance aspect when going full C#. It’s a lot faster than GDScript itself already, and on top of that you can use SIMD datatypes from the .NET runtime without any extra work. (System.Numerics). Godot itself doesn’t have SIMD yet, making C# a lot faster than C++/GDExtension for all kind of vector operations at the moment.

The slowest C# part still is the interaction with the engine itself, which can be worked around by creating your own engine module in C++ to optimize any data transfers between Godot and the .NET runtime. (The C++/C# glue code is easily auto-generated, but I think that goes a bit too far now…)

Of course you won’t even need that if you do as many things as possible in C#. Here are some examples for things I’ve implemented in C# over the last year instead of relying on the engine:

  • File access (using System.IO)
  • Resource loading & savegame serialization
  • TCP networking (async + multithreaded)
  • Physics (BepuPhysicsV2)

Anyways, if you really have that much C# experience: use it. You’ve found the perfect game engine for it.

4 Likes

I prefer c# because it also means using Visual Studio.

However, using .Net means no Web export.

Thus, I use gdscript and VSCode both of which are good enough.

is should change with new .Net this year

2 Likes

That would be great. Visual Studio is a far superior development environment.

2 Likes