Archived

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

Is C# better for games?

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

Doh, I tried searching but I recieved this error 3 times:


Microsoft OLE DB Provider for SQL Server error ''80040e14''
The query contained only ignored words.
/community/forums/search.asp, line 79


(I searched for ''C#'' and ''C flat'' within Game Programming)

Downloads, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Share this post


Link to post
Share on other sites
I think you meant C-sharp, though C-flat seems a much more fitting name to me =)

just so ya know, -flat is symbolized by the little b looking thing after the note, sharp is #

-noh

Share this post


Link to post
Share on other sites
C# is a Microsoft''s Java.
Java is used mostly for business network applications.
And so C# - just as Java - is not very usable for games coz it''s slow and doesnt allow to access hardware directly.

Share this post


Link to post
Share on other sites
There is a point here though - C# and .NET are both very hostile to search engines. Not even the one on MSDN handles them very well.

quote:
Meduzza
And so C# - just as Java - is not very usable for games coz it''s slow and doesnt allow to access hardware directly.


No modern operating system lets you access hardware directly, so the point is moot. C#/.NET has an edge over Java through a more seamless interop mechanism with existing technologies. While Java tends to be an all or nothing solution(Java Java über alles), C# makes it a lot easier to use existing C or COM API''s.

As I have mentioned earlier in other threads - there will be a managed wrapper in DX9, allowing .NET apps to use DirectX. You can presently use the existing VB interfaces through COM interop, or make your own wrapper in Managed C++. There is also an OpenGL wrapper for C#/.NET at csgl.sourceforge.net

The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)

Share this post


Link to post
Share on other sites
C# was made with the purpose of giving Microsoft some ground on yet another industry. Same goes with MSN to AOL, and Xbox to PS2. Microsoft wants to dominate every aspect of technology. C# and Java is an example of the same thing. Microsoft is very compeditive, and they cringe at the prospect of letting any aspect of technology being dominated by another company.

By the way, I'm a total Microsoft fan. I would die without my Xbox, Windows, and Visual C++. Just stating truth is all.

EDIT: Some gramatical errors

Edited by - Johnny_W on February 17, 2002 6:29:00 PM

Share this post


Link to post
Share on other sites
Its funny how people bash C# based soley on the fact that Microsoft created it. I hate Microsoft for many things, but C# is definitly not one of them. In responce to its speed: Yes, C# is interpreted similarly to Java which makes it slow. HOWEVER the interpreted code is compiled while being interpreted so it is faster on the second execution. Whats great about this is that while the game or whatever other application would run slow for a few minutes or every time a new block of code is executed, the second time though (and the next time you run it) the code has been optimized with the current system in mind and in effect could actually run faster than C++ because of the automatic configuration-dependant optimazations. Also you can configure the Microsoft Installer to compile it when installing, this will slow down installation however the app will run fast the first time. If the system configuration or settings change the code is automaticly recompiled to ensure optimal performance. Not to mention the language has a ton of awsome features and the .NET Base Classes are very very good.

Share this post


Link to post
Share on other sites
quote:
Original post by SnprBoB86
Yes, C# is interpreted similarly to Java which makes it slow. HOWEVER the interpreted code is compiled while being interpreted so it is faster on the second execution.

Close, but no cigar - the MSIL is never interpreted. It is compiled by the JIT-compiler to native x86(for now, at least) code, and then executed.
The rest of your post was pretty accurate though.

Share this post


Link to post
Share on other sites
quote:
Original post by Johnny_W
C# was made with the purpose of giving Microsoft some ground on yet another industry. Same goes with MSN to AOL, and Xbox to PS2. Microsoft wants to dominate every aspect of technology. C# and Java is an example of the same thing. Microsoft is very compeditive, and they cringe at the prospect of letting any aspect of technology being dominated by another company.


Just makes me think - if the roles were reversed and MS had introduced Java 7 years ago instead of Sun, and Sun just now came up with .NET - wouldnt we all be cheering the fact that there was finally some competition in the field?

Share this post


Link to post
Share on other sites
quote:
C#/.NET has an edge over Java through a more seamless interop mechanism with existing technologies.

Java has a clearer separation between cross-platform and platform dependent code but I hardly see that as a disadvantage.

quote:
While Java tends to be an all or nothing solution(Java Java über alles),

Yeah, this is coming from someone who is advocating the use of a Microsoft technology, a company that is SO known for supporting interoperability with other''s solutions. One C# to rule them all, One C# to find them, One C# to bring them all and in .NET bind them.

Share this post


Link to post
Share on other sites
quote:
Original post by Arild Fines
No modern operating system lets you access hardware directly, so the point is moot.


Ahem... go make a DOS game in mode 13H and then tell me that no OS lets you access hardware directly...

...oh wait, "modern"... and "operating"... my bad.

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

Share this post


Link to post
Share on other sites
It was a joke, Henry - lighten up. I like Java.
As for..
quote:

Java has a clearer separation between cross-platform and platform dependent code but I hardly see that as a disadvantage.


Does this mean that you agree that Java has a clunky mechanism for interoperating with native code, but that you see this as a plus?

Share this post


Link to post
Share on other sites
quote:
Does this mean that you agree that Java has a clunky mechanism for interoperating with native code, but that you see this as a plus?

Well, I do not think JNI is particularily clunky per se. Sure, it is clunkier than being able to accidentally tie yourself to one platform by careless use of a pointer in an unsafe block, but that I do see as a plus. In Java you get a clear platform independent interface towards the platform dependent code, an interface that enables porting of the platform dependent parts of the app. I value that separation.

Share this post


Link to post
Share on other sites
quote:
Original post by HenryApe
Sure, it is clunkier than being able to accidentally tie yourself to one platform by careless use of a pointer in an unsafe block, but that I do see as a plus.


First - P/Invoke(the mechanism used to access C-style API''s exported from DLL''s) doesnt require pointers or unsafe blocks. You simply declare the imported function as a static extern method of your class, and in some cases applying some attributes for marshalling datatypes(gotta love .NET metadata).
Second - the fact that you have to use the word ''unsafe'' doesnt really invite ''careless use'', does it?
quote:

In Java you get a clear platform independent interface towards the platform dependent code, an interface that enables porting of the platform dependent parts of the app. I value that separation.


In what way is Java''s ''interface towards the platform dependent code'' any more platform independent than .NET''s? Isn''t that a contradiction in terms?
If you have to resort to P/Invoke calls on multiple platforms in C#, you could just wrap the static extern declarations in a couple of #if/#endif''s.
AFAIK, there is no way in Java to use a C-style API directly - you have to write a wrapper(correct me if I''m wrong). This is one extra layer of indirection, which I find slightly clunky.

The bottom line is - many people have a lot invested in ''legacy'' codebases. The fact that .NET allows easy access to these codebases might in the end be what gives .NET an edge over J2EE.




The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)

Share this post


Link to post
Share on other sites
quote:
Second - the fact that you have to use the word ''unsafe'' doesnt really invite ''careless use'', does it?
I think it does because unsafe blocks have a double meaning in that they allow both platform-dependent functionality and ''pure C#'' optimizations, such as turning off the GC and removing bounds-checking. The latter is probably how the feature will mainly be used by C# programmers so it can be quite easy to get careless about the former. When you come across a JNI interface in Java you can be sure it means that platform dependent code is being used.

quote:
In what way is Java''s ''interface towards the platform dependent code'' any more platform independent than .NET''s? Isn''t that a contradiction in terms?

No, because you can perform platform dependent operations in C#, inside unsafe blocks, something that you can not do in Java. With Java you know that all your .class files are portable.

quote:
AFAIK, there is no way in Java to use a C-style API directly - you have to write a wrapper(correct me if I''m wrong). This is one extra layer of indirection, which I find slightly clunky.

Yes, you do have to have a wrapper, but again, I do value the clear separation between cross-platform and platform-dependent code. Writing a wrapper did have functional consequences before JDK1.4, but with the mapped memory buffers in the new java.nio packages I think the differences that remain are mainly in the areas of clarity and safety.

quote:
The fact that .NET allows easy access to these codebases might in the end be what gives .NET an edge over J2EE.

Most of the features in C# are ok and I really would not mind seeing the foreach keyword in Java, but I do think the way C# handles unsafe code and the absence of checked exceptions are serious problems for library developement and code reuse. One of the big advantages for Java in J2EE development is that Sun has kept the language clean, C# feels more like a hack-job. C++ programmers might like it better though.

Share this post


Link to post
Share on other sites
I pronounce it C-hash, because that''s what I''d need to smoke before using it. Or C-pound (on my head). Or C-diese, because their clever word trick doesn''t translate in French.

Share this post


Link to post
Share on other sites
Quick fact sheet on the .Net framework: http://msdn.microsoft.com/netframework/prodinfo/frameworkfacts.asp

Intro to C#:
http://msdn.microsoft.com/vstudio/techinfo/articles/upgrade/Csharpintro.asp

Go cruise around the msdn.microsoft.com and www.gotdotnet.com websites for all the info you need on C# and .Net.

Edited by - jbattist on February 18, 2002 9:38:42 AM

Share this post


Link to post
Share on other sites
quote:
Original post by HenryApe

[quote]
No, because you can perform platform dependent operations in C#, inside unsafe blocks, something that you can not do in Java.


There is nothing inherently platform dependent about what you do in an unsafe block - I think you are yet again confusing P/Invoke and the unsafe keyword. Unsafe blocks only let you perform pointer arithmetic, which should port without a problem in a language which has fixed sizes for all datatypes.

quote:

and ''pure C#'' optimizations, such as turning off the GC and removing bounds-checking.


You cannot use an unsafe block to turn off the GC. The thing you _can_ do is make sure the GC doesnt move an object while operating on it. As for bounds-checking - well, sometimes you can do without that overhead.
quote:

When you come across a JNI interface in Java you can be sure it means that platform dependent code is being used.


Any use of P/Invoke, COM Interop or unsafe blocks means that the assembly will not be trusted, and can only be run in a trusted environment.

I maintain the point that the word ''unsafe''(plus the fact that the docs generally advice against using it) makes it pretty clear that this is something you should only use after giving it some serious thought.
I''ve seen a lot of C# code, and unsafe blocks are used very seldomly.
If you are interested in more accurate details about unsafe blocks in C#, I suggest you check out these two articles by Eric Gunnerson: http://msdn.microsoft.com/library/en-us/dncscol/html/csharp10182001.asp and http://msdn.microsoft.com/library/en-us/dncscol/html/csharp11152001.asp



quote:

Yes, you do have to have a wrapper, but again, I do value the clear separation between cross-platform and platform-dependent code. Writing a wrapper did have functional consequences before JDK1.4, but with the mapped memory buffers in the new java.nio packages I think the differences that remain are mainly in the areas of clarity and safety.


I dont think those wrappers add anything to clarity. They are just another layer that has to be written and maintained. C# lets you use existing libraries without having to write a wrapper.

quote:

Most of the features in C# are ok and I really would not mind seeing the foreach keyword in Java,


How about properties, indexers, delegates, attributes, true multidimensional arrays, operator overloading and the ability to create assemblies dynamically?
quote:

but I do think the way C# handles unsafe code and the absence of checked exceptions are serious problems for library developement and code reuse.


Checked exceptions arent universally accepted in the Java community either - Bruce Eckel wrote the article "Does Java need checked exceptions?" - http://www.mindview.net/Etc/Discussions/CheckedExceptions
quote:

One of the big advantages for Java in J2EE development is that Sun has kept the language clean, C# feels more like a hack-job.


Java is cleaner because it has less features and gives you less flexibility?

Share this post


Link to post
Share on other sites
quote:
There is nothing inherently platform dependent about what you do in an unsafe block

Exactely, so when you get an unsafe assembly you can not be sure whether the author has just used the unsafe code to speed up his library by removing bounds-checking or whether the code makes calls to the native platform.

quote:
How about properties, indexers, delegates, attributes, true multidimensional arrays, operator overloading and the ability to create assemblies dynamically?

Properties, delegates, attributes, foreach are all just different ways to do things that can be done in both languages. It is a matter of personal taste what you prefer and the only thing I miss in Java is foreach, I'm glad that I will not have to learn and look out for the rest of them in other people's code. Operator overloading and indexers have a tendency to destroy clarity so I think Gosling made the right choice when he kept them out of Java.

About assemblys, you can create JAR files dynamicly in Java too, but most times you do not have to since Java's dynamic classloading does not require that you provide an assembly via an URL to load a class.

I have read that true multidimensional arrays can be useful for certain technical applications, but I have never been in a situation where I have needed whatever functionality it is that they provide over Java's nested arrays. I have also not seen them on the Request For Enhancement list for Java so I doubt they are very needed.

quote:
Checked exceptions arent universally accepted in the Java community either - Bruce Eckel wrote the article "Does Java need checked exceptions?"

Is any feature universally accepted in any programming language community? I think checked exceptions have greatly helped library building and code reuse in Java, especially since they automaticly show up in auto-generated code documentation. I am sure unchecked exceptions thrown inside C#'s properties will help drive aspirin sales.

quote:
Any use of P/Invoke, COM Interop or unsafe blocks means that the assembly will not be trusted, and can only be run in a trusted environment.

I am not sure how much this means since security policies are normally set to trust local assemblys.

quote:
Java is cleaner because it has less features and gives you less flexibility?

I think cleanliness IS a feature that is closely related to cooperative development and safety. I value clarity and cleanliness over most features that do not actually provide new functionality but allow programmers to perform the same task in many different, some often confusing, ways. Having too much flexibility is bad in all forms of design, including programming language design. Maybe you do not believe in code conventions either since they hinder flexibility...

Edited by - HenryApe on February 18, 2002 1:56:06 PM

Share this post


Link to post
Share on other sites
quote:
Original post by HenryApe
Exactely, so when you get an unsafe assembly you can not be sure whether the author has just used the unsafe code to speed up his library by removing bounds-checking or whether the code makes calls to the native platform.


You may have a point there, but you are still confusing the keyword ''unsafe'' with the general trust level attributed to an assembly.
quote:

Properties, delegates, attributes, foreach are all just different ways to do things that can be done in both languages.


Of course - but these features invite cleaner looking code, which you have been promoting all along.
However, as far as I know there is no mechanism similar to attributes in Java. You cannot attach arbitrary metadata to classes, methods or method arguments.

quote:

Operator overloading and indexers have a tendency to destroy clarity so I think Gosling made the right choice when he kept them out of Java.


These things destroy clarity too:
  
Complex c1 = new Complex( 4, 2 );
Complex c2 = new Complex( 3, 1 );
Complex c3 = (c1.add( c2.times( 4 ) ) ).dividedBy( 5 );

Operator overloading(an indexer is just a special case of oo) lets you write code in a way that is more natural with regard to the datatypes involved. I _know_ there have been requests to implement oo in Java as well.

quote:

I am not sure how much this means since security policies are normally set to trust local assemblys.


Your point being?

quote:

About assemblys, you can create JAR files dynamicly in Java too, but most times you do not have to since Java''s dynamic classloading does not require that you provide an assembly via an URL to load a class.


I''m not so sure you understood what I meant. .NET has a whole class hierarchy for creating code on the fly - particularly useful for script engines and compilers. This namespace is what the Mono C# compiler uses to generate code.

quote:

Maybe you do not believe in code conventions either since they hinder flexibility...


A code convention is a conscious decision to limit yourself to a subset of the featureset available. It is hardly comparable to being forced by the language designer to accept a limited featureset.





The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)

Share this post


Link to post
Share on other sites
quote:
Of course - but these features invite cleaner looking code, which you have been promoting all along.

I do not necessarily think they invite cleaner code, they just add to the learning curve of the language by letting programmers solve one problem in multiple ways.

In Java you can just declare an interface instead of using a delegate. The only benefit that I have heard of for using a delegate is that delegates support static methods while Java's interfaces do not. However, one of the top 25 RFEs at JavaSoft is to allow static methods in interfaces so it seems that the problem might be solved cleanly, without adding feature bloat in the form of delegates.

quote:
However, as far as I know there is no mechanism similar to attributes in Java. You cannot attach arbitrary metadata to classes, methods or method arguments.

Sure, there is no standardized way to attach such data to Java, but AFAIK attributes are currently only useful to support COM and .NET. If someone comes up with a need to standardize metadata for Java classes, they can just create an interface that returns such metadata, letting classes that want to attach such metadata implement the interface.

quote:
Operator overloading(an indexer is just a special case of oo) lets you write code in a way that is more natural with regard to the datatypes involved. I _know_ there have been requests to implement oo in Java as well.

Yes, and I know it was a very conscious design decision to leave operator overloading out, a decision that I support.

quote:
I'm not so sure you understood what I meant. .NET has a whole class hierarchy for creating code on the fly - particularly useful for script engines and compilers. This namespace is what the Mono C# compiler uses to generate code.

I guess it would be nice to have that in the standard library, but I know such libraries exist for Java too. I did dynamic code generation, compilation and class loading in Java at the last place I worked, even though I am not sure where they got the library I used. The closest you get to this with the standard library is that Sun is letting you redistribute javac with your applications these days

quote:
A code convention is a conscious decision to limit yourself to a subset of the featureset available. It is hardly comparable to being forced by the language designer to accept a limited featureset.

Actually, modern development methodologies such as Extreme Programming do advocate enforcing code conventions too. I think the analogy between clean language design and code conventions is pretty good since both are about esthetical limitations rather than functional ones. They are also similar since you do not need either when working alone but really benefit from both when developing with others and using other people's libraries.

Edited by - HenryApe on February 18, 2002 6:34:53 PM

Share this post


Link to post
Share on other sites