C# - huh?

Started by
36 comments, last by Promit 16 years, 11 months ago
What is C# (C sharp) all about, does it have anything to do with C++ and should it be used for programming games?
Advertisement
C# is a proprietary language created by Microsoft. It derives from C/C++ and other languages like Java and Delphi, and it is still fairly young. Game programming can be done with C#, although the big boys don't use it becuase of the legacy with C++, among other reasons.
Quote:
C# is a proprietary language created by Microsoft.

No it isn't. While it began as a research collaboration between some Microsoft employees and some other people, and it is now controlled by the ECMA standards body. It is not a "proprietary" language, and it is not a "Microsoft" language.

Quote:
It derives from C/C++ and other languages like Java and Delphi

It really only derives from C++ from a syntactical perspective -- they look similar. C# operates under the hood much differently; much more like Java/Delphi than C++.

Quote:
should it be used for programming games?

Sure, it works very well for game development. Better, in many cases, than C++, unless you have certain specific needs (which you probably don't; as the above poster said, it's not used professionally for primary development because of legacy codebases, as well as lack of expertise and lack of platform deployability, et cetera). For a hobby developer it is an excellent tool.
Quote:Original post by Idopik
What is C# (C sharp) all about, does it have anything to do with C++


very little,

c++ is a minimalistic low level language that compiles to machine code, is unsafe and based around privative types and pointers

C# is a feature and library heavy high level language that compiles to a intermediate byte code, with safe typing and is fully object orientated with a unified type system(every variable can be expressed as a object)

syntax aside C# draws more from languages like java and perl
Also, from what I understand, C# is a managed language unlike C++. Meaning in C++ you must free objects created on the heap manually using the delete, Where else in C#, the garbage collector will manage this for you, except you don't know when this will occur.

I'm not an expert at all so correct me if I'm wrong. I'm always up to learning new knowledge and also don't want to have wrong information.

- Ticker14
Quote:Original post by Kaze
c++ is a minimalistic low level language that compiles to machine code, is unsafe and based around privative types and pointers


I'm certainly no elite professional with C++, but IMHO, this statement couldn't be farther from the truth, with the exception of how each is compiled. I'm not sure how anybody that has worked with C++ for any period of time at all would consider the language minimalistic in any way.

If C++ were unsafe, it wouldn't have become the most commonly used language for professional game development. It is the unsafe programmer which causes the application to do unsafe operations. I believe what was meant by saying that it is unsafe is perhaps the fact that the programmer is responsible for freeing up allocated memory and resources after they've been used, whereas with C#, memory management is handled more reliably by not making the programmer entirely accountable. To make a comparison, it's like driving an automatic versus a standard. In an automatic, the clutching is handled by the transmission so the driver doesn't need to worry about it. In a standard, the driver is expected to instantiate the clutch and release it after putting it to use, or bad things could tend to happen. Does that make the car unsafe? No, it simply makes the driver more accountable, but as a tradeoff, gives the driver more control.

As far as being based on primative types and pointers, I don't get that at all. While it contains all of the basic primative types and pointers, the fact that I can declare my own data types, derived types, and customize them in any way I see fit for different purposes, makes me want to believe it's based on whatever data types are needed for the purpose in which they're intended. The whole point, and this is just MHO, of much stricter data type checking, is to keep data overhead at a minimum, instead of having the extra "under the hood" code to just make them all work regardless. That's a very crude way of saying it, but that's MHO.

Don't get me wrong here, I'm not trying to put down C# in any way at all. I think C# is a great language and it most certainly can be used for game programming - and usually with far fewer headaches along the way due to the smoother learning curve. But to push for C# by making C++ out to be some horrific abomination of a language is wrong. C# is simply a higher level language, which is syntactically much like C++, is easier to learn, and takes some of the responsibility away from the programmer. This results in more time learning the art of programming, instead of all of your time learning the language itself.

That being said, there are pros and cons of going either direction, between C# and C++. Going with C# first will allow you to learn how to program quicker and get quicker results, but as the con, you'll also learn to program without any regard to what you're truly doing with the system memory. That means that if you then decide to move to C++, you'll have to learn more about memory management as a starter, or you'll see many, many access violations and undefined behaviours. On the other hand if you start with C++, you'll learn from the start about managing the memory as you go and have more direct control of the system, however as the con, you'll spend much more time on learning these things and the language, which will make getting results take a much longer time.

Note that I'm not endorsing either way to start as being better, just trying to clarify more about the different between them and what might be considered in making the decision on which one to start with.

Scorp
Quote:Original post by Scorp07
I'm not sure how anybody that has worked with C++ for any period of time at all would consider the language minimalistic in any way.


i was mostly referring to the large library set built into the .net framework,

though really using any relative term to describe a language is a bit misleading because they keep getting more abstract

assembly - low level
c/c++ - high level
c# - very high level
ruby - uber ultra high level

Quote:Original post by Scorp07
If C++ were unsafe, it wouldn't have become the most commonly used language for professional game development.

unsafe

Quote:Original post by Scorp07
As far as being based on primative types and pointers, I don't get that at all.

in c++ every variable is a number, even pointers are just a integer an can be, often time accidentally treaded like a regular integer and cause all kinds of memory problems
in c# every variable is a type safe object that inherits from a single objects base class
Quote:Original post by Scorp07
Quote:Original post by Kaze
c++ is a minimalistic low level language that compiles to machine code, is unsafe and based around privative types and pointers


I'm certainly no elite professional with C++, but IMHO, this statement couldn't be farther from the truth, with the exception of how each is compiled. I'm not sure how anybody that has worked with C++ for any period of time at all would consider the language minimalistic in any way.


I would call C++ minimalistic. There's nothing built into the syntax of the language for strings, lists, dictionaries, etc. You can access most of the missing features through STL and boost but the code is almost always lengthier than other langauges and the fact still remains that these features exist outside the basic syntax of the language.

Quote:If C++ were unsafe, it wouldn't have become the most commonly used language for professional game development.


And think about all the time spent fixing bugs caused by unsafe operations.

Quote:As far as being based on primative types and pointers, I don't get that at all.


How much experience have you had with other languages? For example, have you tried python?
....[size="1"]Brent Gunning
Quote:
And think about all the time spent fixing bugs caused by unsafe operations.

And did C++ create these errors or did you?

Like stated before, With C++ you have more control becuase the C++ expects the programmer to not make these mistakes and C# does not give the programmer the chance to makes these mistake but you lose so control that you had in C++, its a tradeoff.


C# is an excellent language for any kind of programming. The largest hurdle you are going to run in to with C# (or any Managed language) is libraries. The .NET Framework is large and extensive, but it contains very little in the way of "game specific" objects. There is a literal crap ton of libraries for C++ out there that handle everything from physics, to sound, to AI, to path finding to scripting. In C#/.NET you are going to be more limited in your library choices. Many libraries these days have some kind of managed core wrapper, but they aren't always stable and sometimes they are missing features.

Where I think C#/.NET is really shining in the game development arena, and professional trends show this, is tools. WinForms is a great library to write Windows applications in. There are so many neat custom controls and GUI libraries out there that you can create a really advanced UI without a ton of work. Go look at NWN2's editor sometime. That was written in C# using WinForms.

This topic is closed to new replies.

Advertisement