Java vs. C#

So for a college class I’m doing my first coding in C#. It’s a strange language, and I’m not quite sure what I think… there are aspects I both do and don’t like. On the whole, I don’t think it’s as good as Java, but I’m still not 100% decided on my stance.

For all of you who’ve done some work in C#, what’s your opinion? How does it stack up against Java?

It’s a copy of microsoft, as they copy everything successful.
Also windows only. Of course it is possible somehow to program for other OS’s, but obviously MS wouldn’t want that.

I just laugh at it.

Unless I’m gonna port a game to XNA / XBLA, not going to use it D:

I agree, it’s Microsoftyness and single-platformness are definite downsides. My question was more to ask “What features of C#, if any, would you like added to Java?”

Also, “Are there any aspects of the syntax of C# that you prefer to those of Java?”

It’s such a childish thing to claim. C# is packed with features that Java doesn’t have, such as LINQ, (proper) unsafe code and asynchronous methods. C# also got WPF, whilst Java is still waiting on a half-decent version of JavaFX. Lets not forget that Java is getting lambdas after C#, and is copying the syntax.

But does anyone really care?

Again, if you just did research you’d know this isn’t true.

Mono is pretty stable on Linux, and has never been threatened by MS, ever. Microsoft have even standardized C# and parts of .NET as ECMA standards, released under licenses which make it perfectly legal to implement them, which in turn helps Mono development. They did not have to do these things. MS even helped to implement Moonlight.

Personally, if your building for Windows, then use C#, especially if your building an application because WPF is truly brilliant. If you building for non-Windows, then use Java. With XNA you can also target Silverlight, as well as XBox and PC. This will mean you could also build your game as a Metro app, and release it in the Windows store.

One of the main issues with Java is around the game libraries. Only a couple (LWJGL and JMonkey) are actively developed, the rest either get occasional updates (like JOGL) or are simply old and left to die (Java 3D). On the flip side, game development with C# is far more active, and has far bigger ecosystems. For example there are more books on using XNA, then there are game development books on Java. You’ll find more tutorials, frameworks, communities, libraries and games relating to C# then Java.

But ultimately my advice would be to 1) work out what exactly it is you want to build, and 2) try them both out for yourself.

[quote=“JL235,post:4,topic:37289”]
Sorry for the OT, but I keep seeing this lately. It’s not true and I wonder why it’s been repeated so much. JOGL and the other JogAmp projects are updated much more frequently than LWJGL, on a daily basis even. Sven and Michael have put so much work in it and it’s unfair to keep reading things like JOGL’s been abandoned and stuff.

[quote=“Spasi,post:5,topic:37289”]

Ok, then I stand corrected.

But even on that point alone, there are still more DirectX bindings for C#, then there are OpenGL bindings for Java. That doesn’t include the OpenGL alternatives for C#, and you can even use DirectX and OpenGL directly, which you cannot do with Java. This shows how C# game development is much more active.

C# got XNA. And Mono. So C# is all the places Java simply can’t be. Sucks.

Cas :slight_smile:

C# has basic coroutine support, which is quite nice (provided you understand the caveats); and I’m a fan of extension methods (although I find that I need to use them more than I should because of some obvious errors in the library design). The using keyword is a nice piece of syntax sugar, and so is event (although it could be done better).

My projects use .Net 3.5, so I’m not familiar with the changes to the type system in 4. In 3.5 the type system is behind Java’s when it comes to generics. And the biggest gripe I tend to have is bizarre choices in the library design. I’m not at all convinced by the merging of input and output streams into a single Stream, and the design of System.Security.Cryptography with the same object serving as key and cipher object is baffling. (Mind you, I’m moving towards using BouncyCastle, which has been ported from Java, for preference). And if you look at the collections, why is AddRange declared in List rather than ICollection?

WPF is very nice. It can get complex with proper use of the MVVM pattern and IoC…
I think Java is simpler and easier to understand when it comes to big projects.

Between Java and C#, I give Java the edge for libraries, and C# gets the point for the language features.

Neither of them hold a candle to Scala though. You want well-designed type system and collections, you just can’t do better, and it has enough syntax sugar to give you diabetes. There’s a .NET target for scala, but it’s always lagging behind.

C# is fine, but it’s a closed platform. I’m not interested in learning any language which doesn’t work across different operating systems and architectures. Life is too short for that crap.

Mono is lagging behind and far from being complete.

Java is free, C# not. That’s answer everything.

Dirt is free and food is not…that kind of thing?

I’ve been using C# for a few Unity3d projects so far and the more I use it and learn about it, the more I think it is bloated.
It has some nice features here and there, but there’s so many and a lot of overlap.
Reading through C# libraries seems quite hard as well, as everything is done in unique ways.
Also, I find myself writing worse code in C#. My choices seems to be based on how short I can write things, rather than readability.

If Unity3d supported Java, there would be no reason for me to use C#…

That being said, you should probably ask the question in a more neutral forum, if you want fair answers. Or perhaps ask in both camps for fairness :slight_smile:

  • Scarzzurs

But fair comparison would be Pepsi vs Coke. If another is free and you can drink it every country and other cost money to drink and do not open on some side of worlds. There might be some flavor difference but those who want free drinks don’t care flavor that much.

But flavor IS how people decide what to drink. Also if I never go to the other side of the world, then does it really matter if it is/isn’t available there?

Either way, C# is free in the sense that you don’t pay any money to use it, which is most people’s definition of ‘free’. It’s not free in the sense that you cannot alter it’s insides, and hit compile. But how often has anyone wanted to do that with Java? and is that a requirement when building a game?

Mono is not really stable on Linux. Moonlight is even worse. I don’t like to watch TV, my girlfriend wanted to use Moonlight to watch a tennis match and this thing froze my browser several times. I mentioned an excellent diagram which shows the numerous differences between Microsoft .NET and Mono implementation, it cannot be compared to Java, even OpenJDK and Oracle JVM are closer than Mono & Microsoft .NET.

Of course, ClickOnce only works on Microsoft .NET which is less interesting than our (buggy) Java Web Start, IzPack and GetDown.

This is simply disgusting. Ardor3D is actively developed like JGame, Slick, Libgdx, etc… Java3D has had only a few maintenance loads and is dying but JogAmp is actively maintained (LWJGL too). Maybe there are more books but I disagree with you about tutorials, there are far more resources in Java than in C# and not only about gaming. The real lack is in WYSIWYG editors, only MMF2 partially supports applets, JMonkeyEngine 3 has a GDE (integrated Game Development Environment).

C# cannot be compared with Java in terms of licenses. OpenJDK works better than a few years ago, I use it daily whereas I didn’t dare to do it in 2009. I like free open source softwares :slight_smile:

I would prefer C# to give some of its features, I still don’t like lambdas, closures and their friends. Yes, both languages have diverged but C# was mainly a clone of Java created after the death of Visual J++. Don’t forget that Java itself has its bytecode inspired of Microsoft P code… Microsoft and Sun Microsystems copy :slight_smile:

Edit.: The main C# binding of OpenGL (contained in OpenTk) is 70% slower than JOGL 8)

A cola analogy is not bad. A small number of people prefer one over the other based on taste and the rest have an irrational preference.

Like it or not, the last time I looked windows had around 91% of the market. So for 91% of users, C#/.NET is effectively free. So the whole “free” argument is pretty weak. From a technical standpoint C# and .NET are superior to Java/JVM. Note that I’m not talking about any specific implementation but the design.

For most beginning to intermediate programmers the choice really doesn’t matter. Once you learn one picking up the other will be pretty easy.

I’m an ubuntu man myself. ;D

I don’t like Java that much but I do like Eclipse. Good IDE can raise my productivity by big margin and that is all what matters.