C# newbie help

Community Forums/General Help/C# newbie help

Ferret(Posted 2011) [#1]
I started to learn C#, did some beginner tutorials and 2D stuff with XNA.
Then i got bored and jumped to 3D with the SoftPixel engine.

I still have some newbie, maybe dumb, questions to ask about C#.

Where can i get newbie friendly help, like you get on this forum, with C#?


Yasha(Posted 2011) [#2]
There's a WikiBook, marked as vaguely complete: http://en.wikibooks.org/wiki/C_Sharp_Programming

Microsoft's main reference page: http://msdn.microsoft.com/en-us/library/kx37x362.aspx

Microsoft has community stuff, but it's a bit unfriendly. Mono (the other main C# / CLR implementors) have a community page here: http://mono-project.com/Community

StackOverflow is the best place to ask programming questions: http://stackoverflow.com/

And finally... depending on the question, you might even have some luck asking here. Many Blitzers use C#, more now that Monkey has come out.

My best recommendation is to browse the Microsoft reference for subjects you don't understand, and if their explanation isn't clear enough then search using the technical terms you find there. As the inventors of the language, whatever you find on MSDN is most likely to be correct.


---

If you're still testing the waters and haven't really committed to C# as a language, there are also some alternatives, of which I would heartily recommend Vala: http://live.gnome.org/Vala

Almost the same language as C# (although simplified in places), but with the performance of C++ as it produces native binaries rather than .NET bytecode. It has a reasonably active community too.


Ferret(Posted 2011) [#3]
Thank you for the verry usefull info.

The current plan is to learn c# before moving on to c++, because most engines are written in c++.
I did some research before choosing a language and c# should be easyer to learn and has a garbage colector.


Ferret(Posted 2011) [#4]
How much harder is c++ actualy?


Yasha(Posted 2011) [#5]
Personal opinion:

C++ is an easy language to use badly, and an incredibly hard language to use well. The basic principles of OOP are pretty much the same as in Java and C#, but combine first with all the features of C, and then a second set of duplicated features, to create a language with a massive amount of redundancy and dozens of similar but slightly different ways to do similar things. A lot of these features are also not as well designed as in other languages, and almost all of them were thrown in simply because they sounded good at the time with little or no thought for how they would work together, or even in many cases compete. C++ also does little to encourage or teach good programming techniques (many not even being possible in it), and has no concepts of important things like type safety or encapsulation.

Those high-level features that it does have will usually also come at the cost of performance, meaning that you can either write fast programs in an obsolete subset of C, or buggier and comparatively slower programs using inferior copies of the high-level features in languages such as C#. The huge flexibility also means the language can't benefit from automatic code assistance in IDEs to the same extent as other languages.

Strong personal opinion:

C++ is a hacked together mess, and completely obsolete (as you observed above, it doesn't even have a garbage collector - that's not acceptable in modern language design). It is a nightmare to learn properly. I'd actually advise against learning it at all, because there's simply no need for it now that it's been completely surpassed by several objectively superior languages.

The fact that many existing engines are written in it isn't a good reason to learn it; it's a good reason to learn something else and save the computing world from having to stick around C++ any longer than it has to.

End of opinions

If that came across as a little strong... it was meant to be. I honestly don't believe that you would be helping yourself to learn C++ at this point in history. Other strong competitors with it are:

- C# (for non-game work, you don't need C++'s speed, and C# has type safety, libraries and a GC)
- Java (similar advantages to C#, much better cross-platform compatibility and slightly better jobs available)
- C (C is an excellent choice for implementing select parts of your program that do need performance; it's a much smaller, cleaner language than C++ - and not actually compatible with it)
- OCaml (excellent blend of performance with incredibly strong, safe typing - this one will get you a lot of jobs in the financial sector)
- Vala (as mentioned above, basically similar to C#, but as fast as C++ - meaning there's honestly no reason to use C++ at all now that Vala exists)

... and of course a hundred other things.

I should also point out that "speed" is a vague concept. Compilers for C and C++ have traditionally output the fastest programs, but that's mainly because they were the best compilers. The idea that a GC slows down a program is rapidly becoming outdated; GCs reduce memory fragmentation and generally improve the performance of the memory that has been allocated, and the GCs themselves are very fast indeed at searching for unreachable memory (or in the case of BlitzMax and Vala, use reference counting, which has no noticeable speed hit at all). Languages that make use of Just-In-Time compilers, such as C# and Java, can also take advantage of certain machine-specific optimisations; the Java port of Quake 2 ended up faster than the C original thanks to this!

And on the other side, there's the other kind of speed; developing in a low-level language that provides no solid type-checking and doesn't handle memory for you means that any reasonable program will be fraught with bugs, taking longer (between five and twenty times longer, on average) to develop and make reliable enough for release, all while providing no solid debugging features.


... yeah, that was a rant.

Last edited 2011


Ferret(Posted 2011) [#6]
... yeah, that was a rant.

A verry informative rant and i appreciate your opinions :)

Thats actualy what i wanted to hear, i like c# verry much and i'm going to stick with it for a while.

I put Vala and c on mi list for the reasons you mentioned.
Java is getting interesting because of droid and the similarities to c#.

I never heard of OCaml or needed any financial programs but ill keep it in mind for when i do.