Sign in to follow this  

C# - huh?

This topic is 3864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by RyanZec
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.


You can make the same mistakes in C# if you know how to use unsafe code and fixed pointers. The difference is that C# makes it so you won't accidentally make those mistakes, while C++ has no such protection. You have to be specifically trying to play around with pointers in C#, generally indicating you know what you are doing and why you are doing it.

Share this post


Link to post
Share on other sites
First off, I wanted to thank Scorp and all the others for replying so fast and being of great help.

Second, I wanted to say that so far all the programming I've done was in Java, which from what I understand is the same level as C#. If managing the memory is important at the higher level programming then I suppose it would be best to work in C++, especially if it's the most commonly used language for games nowadays (for some odd reason I thought people were using C# now).

If anyone could direct me to some reading material to get me converted to C++ and tell me which compiler to use (either free or bought) It would be greatly appreciated.
Also, feel free to tell me anything else you think I should know on this subject.

Share this post


Link to post
Share on other sites
Honestly, the "difficulty" of memory management in C++ is enormously overstated. You just have to make sure you delete memory that is dynamically allocated.

I don't think I would choose a language based on whether or not you feel that it will "teach you" to manage memory. That sort of thing can be picked up quickly if and when you need it.

Share this post


Link to post
Share on other sites
Quote:
Original post by RyanZec
Quote:

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

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


Does it matter? They still occur and they're expensive to fix.

Quote:
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.


The "control" C++ gives you has some benefits, but the number of projects that require that level of control certainly does not reflect the number of projects using C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Idopik
tell me which compiler to use (either free or bought) It would be greatly appreciated.

id recomend either

visual c++
microsofts compiler, has good intelisense but its large number of features an build options can be a bit intimidating

dev c++
a open source compilers for windows, a bit lacking in features but very easy to learn to use

Share this post


Link to post
Share on other sites
Quote:
Original post by RyanZec
Quote:

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

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


I did, since I chose to use C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by skittleo
Quote:
Original post by RyanZec
Quote:

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

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


Does it matter? They still occur and they're expensive to fix.

Quote:
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.


The "control" C++ gives you has some benefits, but the number of projects that require that level of control certainly does not reflect the number of projects using C++.


Let me make clear I am not saying that if you are going to make game, use only C++. C# is a great tool if you need something up fast and quick or if game programming is just a hobby. however if you plan to do game programming as a professional, I would say use C++ without and doubt. The reason for this is becuase of the I don't see gaming companies moving away from C++ for awhile for the main reason that there is just a huge amount of C++ code that has not been written in C# and won't for some time. However after saying that, I would still learn C# as even now if is being used by professionals mainly for Game/Engine tools(level editord, etc...).

Share this post


Link to post
Share on other sites
Quote:
Original post by skittleo
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.


I was only addressing the point of C++ being made out to look like you're forced to program with only the primative data types and nothing more. Sure, you may need to delve into the STL to obtain more functionality for strings and containers such as dictionaries. But my understanding was that the advantage here was giving you more control with what you do with it, instead of just giving you a blanket data type and make of its methods what you will. If we're only looking at what the actual core language syntax is, well... I haven't found other languages to have cores any larger than C++, myself, but that's just my experience. It all goes to the main point I was trying to make, and that is if you want the most control, you'll have to get your hands the dirtiest. If the overall goal is to look for what does the most for you without you having to code anything "extra", why stop at higher level languages? Why not just contract to a different developer, tell them what you want and they save you from coding at all. But you've lost all of your control. It's all give and take.

Quote:
Original post by skittleo
And think about all the time spent fixing bugs caused by unsafe operations.

... which were caused by unsafe programming...

Quote:
Original post by skittleo
How much experience have you had with other languages? For example, have you tried python?


The point I was making here also goes right back to my first point, so I'll digress on this one.

Quote:
Original post by skittleo
The "control" C++ gives you has some benefits, but the number of projects that require that level of control certainly does not reflect the number of projects using C++.

I do agree with this whole heartedly, however.

The bottom line of what I was saying is only that they both have pros and cons, nothing more. I personally like both very much, and realize each has its own place. I also agree with smitty in that the memory management isn't that big of deal to learn, procedurally. It's the programming style that you develop, but that can evolve just as easily.

Kaze is also correct on the compilers. I use Visual Studio 2005, and I like it, but it does have a crazy list of features and options, etc.

Anyhoo... the best of luck to you in your endeavors - keep the fun alive!

Cheers!
Scorp

Share this post


Link to post
Share on other sites
Once you learn how to use VS 2005, either for C++ or C#, it really becomes a very productive tool. It has a learning curve, just like any advanced piece of software, but once you learn the tricks and the how to use the tools, it's a great environment to work in.

Share this post


Link to post
Share on other sites
Quote:
Original post by skittleo
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 [...] these features exist outside the basic syntax of the language.

The same is true for Java and C#. The actual Java-language has no knowledge about strings. However, any installation of Java comes with a really nifty library full of stuff like String-classes, data structures etc. You know, just like with C++ and it's runtime library (including STL).

Share this post


Link to post
Share on other sites
Quote:
Original post by DaBono
Quote:
Original post by skittleo
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 [...] these features exist outside the basic syntax of the language.

The same is true for Java and C#. The actual Java-language has no knowledge about strings. However, any installation of Java comes with a really nifty library full of stuff like String-classes, data structures etc. You know, just like with C++ and it's runtime library (including STL).


There is still a difference. You can write, run and ship a C++ program without the STL. You can (and I have) write C++ in environments where the STL does not exist. You can't decouple C# and .NET, or Java and it's libraries, it just doesn't work. They ship as a package. If I am working in C#, I know for a fact I have the .NET facilities at my disposal, it's not something I have to think or care about. System.String will be there and it will have a primitive syntactic sugar element called "string" and it will support all the operations I need it to. Even if STL DOES exist in the C++ environment, is it a good implementation? Does it follow the standard?

Share this post


Link to post
Share on other sites
What's C#? Look here:

http://en.wikipedia.org/wiki/C_Sharp

http://en.wikipedia.org/wiki/Microsoft_Visual_C_Sharp

Can you use C# for game programmming?

Yes, you can. take a look here:

http://msdn2.microsoft.com/en-us/xna/default.aspx

Share this post


Link to post
Share on other sites
Quote:
Original post by GnomeTank
Quote:
Original post by DaBono
Quote:
Original post by skittleo
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 [...] these features exist outside the basic syntax of the language.

The same is true for Java and C#. The actual Java-language has no knowledge about strings. However, any installation of Java comes with a really nifty library full of stuff like String-classes, data structures etc. You know, just like with C++ and it's runtime library (including STL).


There is still a difference. You can write, run and ship a C++ program without the STL. You can (and I have) write C++ in environments where the STL does not exist. You can't decouple C# and .NET, or Java and it's libraries, it just doesn't work. They ship as a package.


Why can't you decouple C# and .NET? I mean, I guess you can't really write an operating system in C#... Oh wait, yes you can.

Share this post


Link to post
Share on other sites
Quote:
Original post by RyanZec
Quote:

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

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


I don't know. Did the chainsaw cut off your fingers or did you? Is the chainsaw safe?

Share this post


Link to post
Share on other sites
Quote:

You can't decouple C# and .NET

Yes you can. .NET is just a CLR implementation, you can run C# on any CLR implementation. Furthermore, nothing in the C# standard really mandates that you use a CLR... you could have the language compile to native code if you liked (though nobody has bothered to implement such a C# compiler).

In any case...

Quote:

You can write, run and ship a C++ program without the STL. You can (and I have) write C++ in environments where the STL does not exist.

There are two things wrong here. First, did you really mean the STL (the old SGI library), or did you mean the SC++L (the modern standard C++ library, which contains some of what used to be the STL)? They are different, although commonly used interchangeable, so clarifying your meaning would help.

I'll assume you meant the SC++L, because that makes the most sense in this context. I'll also assume that by .NET you mean the standard library that is exposed by .NET (all the System.* stuff), since I already pointed out the fallacy in your statements when .NET is taken to mean the underlying common language runtime implementation.

In that case, you're still wrong. Just because you ship code that does not utilize the SC++L does not mean it isn't there. Likewise, just because you ship code that makes no reference to the System namespace doesn't mean it isn't there. But you can, in fact, ship code in both C++ and C# that does not make use of the standard library as long as you rely appropriately on 3rd party libraries (otherwise there's actually very little you can do with the language).

This tends to be true of many languages, in fact. The actual language intrinsics portion of a language tends to be very limiting, and the standard library facilities (built on top of those basic intrinsics) tend to be what gives many languages their expressiveness and power. The way that many modern languages (and even C++ is moving in this direction) entangle their language intrinsics with their standard library (for example, as syntactic sugar) is becoming increase more common and pervasive, so it makes even less sense nowadays to consider a language without its standard library.

Note that you can make the argument that you worked with an implementation of language X that lacked its standard library (for example, C++ without any of the standard headers), but this really doesn't hold up because such an implementation is not standard-conforming, at which point you can say, make or do pretty much anything with said implementation since it has no baseline. Consequently, any remotely standards-conforming C++ environment should ship with a remotely-standards-conforming implementation of the SC++L (but not necessarily the STL, as its the SC++L that is detailed in the C++ Standard document, not the STL, which is technically a 3rd party library despite what the S stands for).

Share this post


Link to post
Share on other sites

This topic is 3864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this