Jump to content

  • Log In with Google      Sign In   
  • Create Account


C# - huh?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
37 replies to this topic

#1 Idopik   Members   -  Reputation: 122

Like
0Likes
Like

Posted 17 May 2007 - 07:08 AM

What is C# (C sharp) all about, does it have anything to do with C++ and should it be used for programming games?

Sponsor:

#2 Shakedown   Members   -  Reputation: 230

Like
0Likes
Like

Posted 17 May 2007 - 07:12 AM

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.

#3 Josh Petrie   Moderators   -  Reputation: 2954

Like
0Likes
Like

Posted 17 May 2007 - 07:22 AM

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.

#4 Kaze   Members   -  Reputation: 948

Like
0Likes
Like

Posted 17 May 2007 - 07:31 AM

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

#5 Ticker14   Members   -  Reputation: 122

Like
0Likes
Like

Posted 17 May 2007 - 07:49 AM

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

#6 Scorp07   Members   -  Reputation: 133

Like
0Likes
Like

Posted 17 May 2007 - 08:21 AM

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

#7 Kaze   Members   -  Reputation: 948

Like
0Likes
Like

Posted 17 May 2007 - 08:47 AM

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

#8 gunning   Members   -  Reputation: 751

Like
0Likes
Like

Posted 17 May 2007 - 08:47 AM

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?

#9 RyanZec   Members   -  Reputation: 124

Like
0Likes
Like

Posted 17 May 2007 - 08:55 AM

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.




#10 GnomeTank   Members   -  Reputation: 190

Like
0Likes
Like

Posted 17 May 2007 - 09:02 AM

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.

#11 GnomeTank   Members   -  Reputation: 190

Like
0Likes
Like

Posted 17 May 2007 - 09:04 AM

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.

#12 Idopik   Members   -  Reputation: 122

Like
0Likes
Like

Posted 17 May 2007 - 09:05 AM

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.

#13 smitty1276   Members   -  Reputation: 560

Like
0Likes
Like

Posted 17 May 2007 - 09:14 AM

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.

#14 gunning   Members   -  Reputation: 751

Like
0Likes
Like

Posted 17 May 2007 - 09:17 AM

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++.

#15 Kaze   Members   -  Reputation: 948

Like
0Likes
Like

Posted 17 May 2007 - 09:23 AM

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

#16 Ezbez   Crossbones+   -  Reputation: 1164

Like
0Likes
Like

Posted 17 May 2007 - 09:25 AM

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++.

#17 RyanZec   Members   -  Reputation: 124

Like
0Likes
Like

Posted 17 May 2007 - 09:28 AM

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...).



#18 Scorp07   Members   -  Reputation: 133

Like
0Likes
Like

Posted 17 May 2007 - 09:34 AM

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


#19 GnomeTank   Members   -  Reputation: 190

Like
0Likes
Like

Posted 17 May 2007 - 09:40 AM

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.

#20 DaBono   Members   -  Reputation: 925

Like
0Likes
Like

Posted 17 May 2007 - 09:59 AM

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).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS