Scripting with C#

Hello guys,

I have a question. Beyond alpha2 I read that Godot will feature C#7.0 as an option for scripting.
I just know a bit of C, but my main language I would say it is C++.
I did a bit of research regarding books for C# and I managed to find (I guess) two good ones.
Which one of those have you read or, if none of them, which other book would you say is a good, quality source to sink a couple of weeks learning to get a person ready for C# with Godot?
1. https://www.amazon.com/C-7-0-Nutshell-Definitive-Reference/dp/1491987650/ref=sr_1_1?s=books&ie=UTF8&qid=1509131516&sr=1-1&keywords=c+7.0+in+a+nutshell
2. https://www.amazon.com/C-Players-Guide-3rd/dp/0985580135/ref=dp_ob_title_bk?dpID=518ICtY7heL&preST=SX218_BO1,204,203,200_QL40&dpSrc=detail

Best Answer

  • SomnivoreSomnivore Posts: 102
    Accepted Answer

    I learned C# from internet tutorials, they're just as good if you ask me. If you already know C++ it's pretty easy to pick up on the syntax.

    http://csharp.net-tutorials.com/

    Perhaps the biggest difference I can think of is that you don't need to worry about pointers or addresses; objects are always passed by a copy of their address (though you can ref to get the original address var), and structs are always passed by a copy of their value. So you won't have a bunch of * everywhere, which is nice. You also don't have to worry about freeing memory, GC will take care of it, which is nice. Class definition and implemention are in the same file instead of two, which is nice (but you have to assign access modifiers per member and per method, which is not nice.) Instead of include, you using, which you gotta do with System.Collections.Generic to get access to the best data type, List<T>, which is similar to C++'s vector.

Answers

  • NeoDNeoD Posts: 155Member

    Hello. I can't answer this but let me share a thought. As you said C# is optionnal, it was implemented to attract game developers already used to this language. Otherwise GDScript is fine for most scripts in a game.

    You are used to C++ so why not using GDNative C++ bindings if you have performance critical scripts ;)

  • SomnivoreSomnivore Posts: 102Member
    Accepted Answer

    I learned C# from internet tutorials, they're just as good if you ask me. If you already know C++ it's pretty easy to pick up on the syntax.

    http://csharp.net-tutorials.com/

    Perhaps the biggest difference I can think of is that you don't need to worry about pointers or addresses; objects are always passed by a copy of their address (though you can ref to get the original address var), and structs are always passed by a copy of their value. So you won't have a bunch of * everywhere, which is nice. You also don't have to worry about freeing memory, GC will take care of it, which is nice. Class definition and implemention are in the same file instead of two, which is nice (but you have to assign access modifiers per member and per method, which is not nice.) Instead of include, you using, which you gotta do with System.Collections.Generic to get access to the best data type, List<T>, which is similar to C++'s vector.

Sign In or Register to comment.