• Advertisement

Archived

This topic is now archived and is closed to further replies.

Whats the big deal with C#

This topic is 5028 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

In a previous post I saw a discussion on why game developers don''t use C#. The discussion covered numerous areas of compiler numbers , students etc. What nobody questioned was why (apart from the fact it is a new language) would you use it? what does it do that is better than c++ for games? Even if C# was available for console development, why would you use it over C++? I have never looked at C#, but have heard people commenting on it being very good, but offering nothing to back this up. As a professional game developer for over 10 years, I have almost exclusively used C or C++ with no problems, but I think things are a little defferent now than in the past. Now more games are required to be networkable (LAN/internet/whatever) some publishers even make it a pre-requisite, even consoles are in on it, and they are the driving force for many developers. If C# offers better tools for networking then it might make sense to look at it further, but games are fine running on C/C++ versions right now, so again, it begs the question of why change? I am really asking these questions to people who use C# as thier primary (professional) language because, I would really like to know what it does well, and what it does not do well.

Share this post


Link to post
Share on other sites
Advertisement
Spend two days on C# and do some tutorials and you will understand the difference...


Have fun
Bunnz
Purple#, a shader-driven game engine for .NET.


[edited by - Bunnz on April 16, 2004 5:10:37 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Dot5
Even if C# was available for console development, why would you use it over C++?
Because it''s clean and C++ is filthy? Because C++ is huge, crufty and encumbered in an increasingly laborious legacy? Because Bjarne Stroustrup (the creator of C++) has said that "within C++ is a simpler language struggling to get out"?

quote:
I have never looked at C#, but have heard people commenting on it being very good, but offering nothing to back this up.
Well look at it!

quote:
I am really asking these questions to people who use C# as their primary (professional) language because, I would really like to know what it does well, and what it does not do well.
The web is littered with such evaluations.

Share this post


Link to post
Share on other sites
"I am really asking these questions to people who use C# as thier primary (professional) language because, I would really like to know what it does well, and what it does not do well."

Actually, I think you hit on the difference right there. I use C# because it lets me write code faster. I am not a professional, I''m a hobbyist. It''s about finishing projects before I lose interest. Maybe I am wrong, but I don''t get the feeling that many people here are using C# for professional game development.

I don''t know if C# has any value for professional developers. If you''ve been working in industry for 10 years you''ve no doubt noticed the ever-increasing complexity of software projects. C# provides some good tools to manage that complexity (better OOP, GC, ect). But of course others will argue that a good OOP design will do that regardless of what you are coding in. I suspect with .Net 2.0, C# will probably really take off. Maybe not for game programming, but definitely for everything else.

----------------------------------------
Let be be finale of seem, seems to me.
----------------------------------------

Shedletsky''s Code Library:

Open source projects and demos

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
Because Bjarne Stroustrup (the creator of C++) has said that "within C++ is a simpler language struggling to get out"?



Well the quote, as printed in D&E goes "Within C++, there is a much smaller and cleaner language struggling to get out." And to be fair, he''s also gone on the record saying that he doesn''t think C# is that smaller and cleaner language.

Not trying to start a fight, just nitpicking. I happen to like C#. Once you get used to its semantics, it becomes much easier to write a functional, correct applications-level program in C# than it would be in C++.

Share this post


Link to post
Share on other sites
quote:
Original post by SiCrane
Well the quote, as printed in D&E goes "Within C++, there is a much smaller and cleaner language struggling to get out." And to be fair, he''s also gone on the record saying that he doesn''t think C# is that smaller and cleaner language.
Of course he doesn''t, but Alexandrescu (widely considered the father of generic programming) has pooh-poohed C++ templates, saying something along the lines of "when I invented generic programming, I didn''t have C++ in mind."

Language inventors are a parochial bunch. I accept their objectivity as far as it concerns criticizing their own languages, and no further.

Share this post


Link to post
Share on other sites
Oluseyi:
why is C++ filthy, huge and "encumbered in an increasingly laborious legacy"? Is that something you have read, or come to the conclusion yourself? I do not find that to be the case (unless you are on about using MFC or other such tool).

There is a difference in my "looking at it" and talking to people who have used it properly as part of thier job for a sizeable project.

-----------------------------------------------------------

I was asking this because people could argue the reasons why Java isnt used for games dev. You could say its slow, crap, whatever but Java is still a useful language for its own reasons, and yes even for games it has advantages. You could look at the on-line evaluations of C# vs C++, but still miss the point of what it provides in terms of the development cycle as well as the finished product.

Telamon:
good points raised there. Thanks. It always concerns me when people talk about new languages offering better OO or better memory management/bounds checking or whatever because thats the job of the programmer anyway. Quite rightly you clarified this in your reply.

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
Of course he doesn''t, but Alexandrescu (widely considered the father of generic programming) has pooh-poohed C++ templates, saying something along the lines of "when I invented generic programming, I didn''t have C++ in mind."


I don''t think that *anyone* truly likes the way C++ templates were implemented.

quote:
Original post by Dot5
why is C++ filthy, huge and "encumbered in an increasingly laborious legacy"? Is that something you have read, or come to the conclusion yourself?


Oluseyi did embed several links in his post. But again, bringing in the Man (Bjarne Stroustrup) again; Stroustrup has repeatedly said that many of the features and syntax of C++ would be much cleaner if it didn''t support backwards compatability with C. And the direction that C is evolving makes future compatability a fairly large issue. Take for example the additional macro and pointer syntax features being proposed for the next C revision. My personal prediction is that if C++ continues to attempt to support compatability with all future C revisions, its going to implode, even despite the work the two standards committees are doing to maintain sanity.

Share this post


Link to post
Share on other sites
A couple of months ago there were 2 articles in c''t, a (actually the) German computer magazine.

I don''t have the article here, so I can''t post any exact numbers, but here''s what I remember:

The purpose was to compare the speed and efficiency of C++, Delphi, C# and Java. So they wrote programs in each language to do the same things, the programs were similarly structured but using some of each language''s typical features IIRC.

In the first article the non-OOP performance was tested and in the second the OOP performance. I know this is very vague, I don''t quite remember what the programs they wrote really did and what the most intensive tasks in these programs were.

For the non-OOP stuff, C++ scored really good, significantly better than Java and C# (I think they were about the same), Delphi was far behind due to some compiler bug (it was explained but I don''t remember).

For the OOP stuff however, C++ scored the worst. Delphi, C# and Java were much faster in that test, I don''t remember any details though, sorry.

Of course they said that it depends very much on what exactly you want to do and that these benchmarks were not representative for all situations etc, but it was quite interesting though.

If someone who has access to the magazines wants to look it up, the articles were in this and this issue.

I''ve been using C# for 5 months (not for games, I''m currently working on a form editor for a medical software) and I really like it. I don''t know C++ well, so I''ll not try to compare them, but from what I''ve seen many (most?) C++ developers who change to .net start learning C# instead of using managed C++ (quote from a book I have: "I''d rather have my teeth drilled than program in managed C++")

Share this post


Link to post
Share on other sites
I emmigrated to C# / Managed DirectX from C++ / Native DirectX because I discovered that it takes much less time to do what you want using C# / Managed DirectX. The .NET classes are many, many times more structured than the Win32 API counterparts. Also, Managed DirectX does a lot of low level stuff for you that is nothing but time-consuming and boring to write for yourself. And as someone stated, as hobbyist, chances are that I actually might complete my projects .

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I made up the term ''object-oriented'', and I can tell you I didn''t have C++ in mind - Alan Kay, OOPSLA ''97

Share this post


Link to post
Share on other sites
The big deal with languages like C# and Java is that the code is managed. I can''t comment on c# but Java makes it a lot easier for the programmer by helping to manage memory and deal with array bounds, etc.

Imagine this,

int numbers[10];

for (int i = 0 ; i < 11 ; i++)
numbers = i;

What happens in C++? One of two things, 1) Nothing. 2) A segmentation fault.

If you did the following in Java (and probably C#) you would get an Array out of Bounds Exception. It''s little things like that that make a difference.

Why would you want to use something like Java instead of C++? Java has the major advantage for being a run anywhere technology. This is a major advantage it currently has over C++ (and C#). Another major advantage that Java has over C++ is the staggering amount of mature libraries and drivers that can be used within the enterprise (which, again, is another advantage is has over C#).

You''re probably thinking that Java and C# are slower than C++... and you''d be suprised to discover that in some areas Java is actually faster than C++.

Managed code is going to be big in the next few years... At least Microsoft are hedging their bets on it.

Share this post


Link to post
Share on other sites
quote:

I suspect with .Net 2.0, C# will probably really take off. Maybe not for game programming, but definitely for everything else.



Why not for game development? When jitting the compiler has much more information about the target system, so wouldn''t it be possible to gain performance in many cases by using system-specific optimizations? I really don''t know, but I was wondering about that before.

Share this post


Link to post
Share on other sites
These seem relevant.

quote:
I have reaffirmed a long-standing and strongly held view: Language comparisons are rarely meaningful and even less often fair. A good comparison of major programming languages requires more effort than most people are willing to spend, experience in a wide range of application areas, a rigid maintenance of a detached and impartial point of view, and a sense of fairness. -- Bjarne Stroustrup

The next big programming language will be slower than what it replaces. -- Todd Proebsting

Source

Share this post


Link to post
Share on other sites
quote:
Original post by itachi
Why not for game development?
The pros want to port or make their games often for several consoles and the amateurs want to use the languages that the pros use. When C# & .NET actually run well on more platforms, things could change.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by itachi
A couple of months ago there were 2 articles in c''t, a (actually the ) German computer magazine.

I don''t have the article here, so I can''t post any exact numbers, but here''s what I remember:

The purpose was to compare the speed and efficiency of C++, Delphi, C# and Java. So they wrote programs in each language to do the same things, the programs were similarly structured but using some of each language''s typical features IIRC.

In the first article the non-OOP performance was tested and in the second the OOP performance. I know this is very vague, I don''t quite remember what the programs they wrote really did and what the most intensive tasks in these programs were.

For the non-OOP stuff, C++ scored really good, significantly better than Java and C# (I think they were about the same), Delphi was far behind due to some compiler bug (it was explained but I don''t remember).

For the OOP stuff however, C++ scored the worst. Delphi, C# and Java were much faster in that test, I don''t remember any details though, sorry.

Of course they said that it depends very much on what exactly you want to do and that these benchmarks were not representative for all situations etc, but it was quite interesting though.

If someone who has access to the magazines wants to look it up, the articles were in <a href="http://www.heise.de/kiosk/archiv/ct/2003/19/204">this</a> and <a href="http://www.heise.de/kiosk/archiv/ct/2003/21/222">this</a> issue.

I''ve been using C# for 5 months (not for games, I''m currently working on a form editor for a medical software) and I really like it. I don''t know C++ well, so I''ll not try to compare them, but from what I''ve seen many (most?) C++ developers who change to .net start learning C# instead of using managed C++ (quote from a book I have: "I''d rather have my teeth drilled than program in managed C++"


Where did you hear this? As you can not write any thing that is not OOP. This is a bogus statement. I do not care about these articles/comparisions as you can see everything in C# is a namespace/class. Which is OOP. Now if this was VB.net then I would say yes its possible, as real CLR compliant language can not implement a "module in VB" as C#,J#,JScript.net can not see "global" level functions that are written there.

Your in no place to compare them at all. As you are not sure about pointers in C#/C++ then you miss what real C++ programmers love about it, "CONTROL".

The reason they say that is because as .net goes your suppose to supply attributes to .net jit for security and other things that are just not the syntax they are used to. Nor is some of the features added very intuitive. But managed C++ means that your not to be allocating memory something C based programmers do all the time. Although you can allocate it if you use pointers you must use /unsafe switch to make it compile.

The blessing C# has that C++ can not do is Garbage collection. And if you have not used pointers I need not continue. There are some weak C++ libraries that can do this but even if the address was deallocated C++ has no way to determine if it was really release somewhere else.

C# is close to what they are used to just that they have to provide "public,private,internal,protected" on the function level instead of until I say otherwise state of mind. Managed C++ has some crap that even MFC users would hate. The blessing of GC and no intrinsic "pointers" that is without "/unsafe" they are hidden from the details of its handling.


In C# everything is type safe. At worst case you need to case something then you can case it as "object" then case as what you need. Or do something like
Type tp = m.GetType();
tp.invokeMember("MethodName",new object[]);

Dynamically get the type information at run time to execute an unrelated peice of code that is basically a black box methodology.

In the case of java the language is interputed which means that the speed is impacted although the claims of the impact are small, I can not say this is true as the math alone will tell you that its a hell of a lot slower than C/C++. The direct comparisions of C# against C++ there is about 3-7% loss of speed. And C# can manage to squeeze out some nitch things faster than C++ writting better machine code as it can see in advanace that this is what you intended. Something C++ can not do as it does not resolve all external uses of a implementation.

One thing I have see is a plug-in feature added to apps. You no longer have to implement some big project to get it done. or release headers for it. I have seen some implement it using C#/VB.net as a scripting language. Which is possible by compile on the fly and code reflection. as you can programmatically write code then compile and run it without human intervention. "CodeDOM" for the .net users.


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For a hobbyist, there is one primary concern when writing a game: Can I actually finish the bloody thing?

If C# helps you write more bulletproof code and to write it faster than in C++, then it''s a win. Period. Portability to consoles and all that is irrelevant for hobbyists.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Where did you hear this? As you can not write any thing that is not OOP. This is a bogus statement.
No, it isn''t.

You can write procedural code in C# or Java; just make everything static. It''s cumbersome, but there''s no performance penalty for doing so. The penalties come in other areas because of the nature of the language.

The rest of your post, obviously, is inaccurate.

quote:
Original post by Dot5
Oluseyi:
why is C++ filthy, huge and "encumbered in an increasingly laborious legacy"? Is that something you have read, or come to the conclusion yourself? I do not find that to be the case (unless you are on about using MFC or other such tool).
This is my personal conclusion, having used C++ for eight years and having been exposed to and used several other languages as well. The legacy issue is obvious: C++ strives to retain compatibility with C, while C ignores C++ and adds features that break the latter. That''s what the links were to.

As for being huge, C had only 12 or 15 keywords until very recently (C99 added the bool keyword; there is a proposal for the addition of a __func__ keyword or something like that), which made it mentally portable - easy to keep the entire language structure in your head. C++ has at least double the number of keywords of C, some with extremely singular uses (operator serves only for operator overloading), making the language harder to fully comprehend. The continuing addition of "features" to make C++ more of a multi-paradigm language are consistently ugly and complicated (templates in C++ have so many inanities and restrictions that they''re a bit of a nightmare) and only reinforce my claim.

Filthy refers to the fact, stemming from the inconsistent featureset and syntax, that implementing C++ is a daunting task. Need evidence/proof? export. It is so hard to implement this keyword that only one commercial offering has done so to date (Comeau C++), and even then it hardly solves the problem. Filthy refers to C++''s lack of an ABI, which introduces all sorts of late binding issues (name mangling is only the simplest of them). Filthy refers to C++''s (C-styled) requirement for forward declaration, which, coupled with the single-pass compilation model, makes the absurdly simple task of building an application rather complex (extern, LNK2001, "undeclared identifier").

You may have become comfortable with C++, but that''s like using Preparation H and deeming your hemorrhoids a "minor condition".

Share this post


Link to post
Share on other sites
I completely agree with Oluseyi''s post above. Although, I just wish to again stress the fact that you cannot compare two languages in the sense that most people in this thread (and in the forum) want to do.

Like for instance, C++ is a dirty and hard language but it gives the user full control over most things happening in code. Direct access to memory being the most important one.

On the other hand, C# is a very clean and beautiful language that is quite easy to learn. It has (and will have even more) performance gains thanks to the .NET runtime enviroment being able to adapt to various machines and thus giving local optimizations without you (the programmer) having to think about it.

Now, you cannot compare the two above statements. You cannot say that C++ is better/worse because... They are two different languages, that''s it.

It all comes down to a matter of opinion. Such as the following scenario:

I really like spaghetti but hate macaronies. That is personal taste even if BOTH fill my stomach and make my hunger cease. Spaghetti works for some, maraconies for some, that''s just the way life is. Stop comparing silly things and just choose what you are most comfortable with as a person. If you really don''t like macaronies, why bash on them? Eat spaghetti.

Share this post


Link to post
Share on other sites
ok, I see your point if you want to look at it that way, however, using C or C++ is a very nice language and only gets dirty and hideous to read if the programmer writes like that. I certainly find new graduates programming methods very different from people who have been in (i can only speak from the position of a games developer because i have never worked on anything else) the industry for a long time. In particular the use of templates and various other little new features, to look at some of the example code you would expect it to come from some completely new language. I use C++ (and have very rarely seen any other usage) as a simple extension to C, where structs are replaced by classes, but still most of the time everything is made public for ease of use (and a notion that it would be faster to access the member direct than through a get/set function call). What I find is its very much cleaner in the way of bugs (than with C), and debugging is a simpler task because you know where the functions manipulating the ''object'' is and can step through, read the memory of and easily find whats going wrong. Only once have I seen templates encouraged in games development, but found that it was becoming a case of use them for usage sake, and many times a cleaner, easier to read and understand version could be achieved with normal C or C++.

I am not standing up saying C++ is the best, or that nothing will rival it, but with all the shouting about C#, if its almost as fast as C but offers a much better development experience in terms of cleaner (ie bug free ) coed with simple bug tracing then it would be something to consider using. I know you can get low down and dirty with C/C++, get taken aback with the shear size of libs/features but essentially you only need a small fragment of it for our use.

Share this post


Link to post
Share on other sites
quote:
Original post by Dot5
...
but still most of the time everything is made public for ease of use (and a notion that it would be faster to access the member direct than through a get/set function call).
...


It seems you''ve missed the point of OOP...

I don''t agree with "you can''t compare languages". I compared C# with C++ and came to the conclusion that C# is a better language. Other people might end up diffrently, but we still compared the languages.

Share this post


Link to post
Share on other sites
quote:
Original post by Enselic
quote:
Original post by Dot5
...
but still most of the time everything is made public for ease of use (and a notion that it would be faster to access the member direct than through a get/set function call).
...


It seems you''ve missed the point of OOP...

I don''t agree with "you can''t compare languages". I compared C# with C++ and came to the conclusion that C# is a better language. Other people might end up diffrently, but we still compared the languages.


No, see, what you did was choose a language out of an opinionated comparison. Meaning, you basically went with the one that suited you the best, which is the right way to do it.

However, doing a true comparison where you can decide which language is better, globally, as; It is good to live, bad to die, you can''t. Because mostly choices we make are based on our opinions, preferences and sometimes the flip of a coin. So, no you cannot compare languages in the true sense. You can however choose a language that suits you better, which is what you did.

Share this post


Link to post
Share on other sites
Since programming in C# requires the .NET framework SDK, does this mean that users of programs written in C# need the .NET framework? I know this is very minor, but if so, it''s a pain to download for those who don''t have it ( I run Win98 SE ).

Stay Clausal,

Red Sodium

Share this post


Link to post
Share on other sites
quote:
Original post by biovenger
No, see, what you did was choose a language out of an opinionated comparison. Meaning, you basically went with the one that suited you the best, which is the right way to do it.

I.e. I compared them?

[edited by - Enselic on April 16, 2004 1:58:34 PM]

Share this post


Link to post
Share on other sites

  • Advertisement