• entries
    383
  • comments
    1075
  • views
    352603

Languages revisited: Why not C#?

Sign in to follow this  

220 views

One thing I left out of my big language post was discussion of C#. I know C# is the new hot thing as far as game development is concerned, at least for lone developers and small teams around these parts, so my choice to avoid it warrants consideration.

The truth is that I do not know that much about C# save for what I have read in forums and articles in places such as GameDev.net. For some reason nothing about it has piqued my interest me enough to look at it further. This is not a good enough explanation, so I did a little bit of digging in C# tutorials and resources on the 'net to try and figure out why C# just does not excite me.

In short, I think there are three main reasons why I do not think I should use C#, at least not yet. These reasons may be irrational or based on faulty information - I really do not know enough about the language to make an accurate judgement. But they are what I currently feel, and at least by posting them here I know that more experienced programmers can correct any misjudgements that I have.



C# is too much like Java

My first big turn-off is that C# feels far too much like Java. If I have my knowledge right this is intentional: C# is Microsoft's take on Java with a combination of some elements from C++. However I have never liked Java that much, so this does not endear C# to me from the beginning.

My dislike of Java probably is pretty irrational, based on both my history dabbling with it and my preferred programming style . I first learnt the language back in the late nineties as an undergraduate. We would use Java as graphics front ends to applications like our large fourth year grand software engineering project. Our lab had all the outdated Sun SPARC terminals, where you would be hoping to get the ones where the monitors were in quality monochrome. Java 1.2 in those days had a reputation to be slow, and that certainly was the case on our hardware. You would spend up towards a minute just for the GUI screens to show up. I never got too deeply into Java in those days, preferring to stick to C.

Then there were my days as a tutor. Amongst the classes I took was one on Human-Computer Interaction, spending a bunch of classes arguing the merits of interface design with disinterested students (computer science students don't seem to like having to deal with tutorials that involve class discussion). Halfway through, it was sprung on me that I also had to take labs in Java. At that time, the only skills I could remember were essentially the bits that overlap with C++. It wasn't pleasant.

These are purely anecdotal and are unfair to current Java, I concede. I am sure that the latest version of Java (it's up to 1.6, I think) on current hardware is nowhere near as painful as it was nearly a decade ago. However it has left me with a slightly negative opinion of the language.

Other slightly more relevant complaints I have about Java: it is increasingly being used as an introductory language for students. Okay, this might also be unfair to Java, as my complaint is more directed towards how it is taught than a limitation of the language itself. Every Java tutorial I have seen has jumped into fancy library calls and GUI elements before I think it is warranted. To show what I mean, here's the first link I got Googling for "introduction to Java", the chapter listing for Introduction to Programming using Java. Note how the chapter for GUI programming comes before the ones for arrays. I think focusing too much on pretty GUIs that early is counter-productive. Early programming should focus more on learning the basics of breaking down problems into programmable elements, not on producing applications! I have seen too many undergraduate programmers who work on the cut-and-paste method; they are good at finding code that solves their task exactly, but they do not understand how it works. Personally, I would recommend something academic and functional like Haskell or some other ML language as a warm up before moving into an industrial language.

My other gripe is one which is slightly more relevant to C# (there's a lot about Java here for a C# post!). I don't like how rigidly object-oriented Java is, and by extension the same applies to C#. This might be a hang-up from my C days, but I don't like forcing everything into objects when it feels more natural not to. I suppose they can be considered another form of namespaces, but even then it seems a bit over the top.

That might have been a bit more ranting towards Java that was necessary. Most of those points are about my own personal tastes and do not apply to the Java and related languages in general. In truth, I don't actually dislike Java, much like I don't dislike any programming language (well, except maybe Perl - wait, better not get side-tracked again). Java just has not gelled with me the times I have tried it; its form and function does not appeal to me as a programmer. Since C# looks very similar at a glance, this opinion has rubbed off on it.



C# is too closely tied with Microsoft

A rather contentious title, to be sure. Don't worry; this won't involve terms like the "evil empire" or misspellings involving dollar signs.

These days I develop on an iMac. I would like to write cross-platform code for both Mac OS X and Windows (at the least. Possibly Linux as well). So the choice of language for production code needs to be painless for developing under Mac OS X as well as deployment for multiple OSes.

While I do know about Mono and the standardisation of the C# standard, I cannot avoid that, much like how Objective C is associated with Mac OS development, whenever C# is mentioned it almost always is treated as being entwined with .NET for Windows. It is assumed that you are compiling with Visual C# under Visual Studio, aiming for Windows or possibly the Xbox 360. There is also the issue that the ties to .NET mean there is an extra condition placed on anyone who wishes to use my applications, which is a complication that can be avoided with other languages.

Consequently, this makes me somewhat wary how painless cross-platform C# will be in practice. It has been annoying enough with C++ to have everyone assume you are using Visual C++ for pre-compiled libraries. I suspect that Mono will always be one step behind Microsoft's version of C#. And there's always the risk that, much like Sun did with Java, Microsoft might get overly protective of improvements to their language.



Other languages will do the job

This reason is straight-forward. The big reason I have against devoting a lot of time to trialling C# is that I feel other languages will work admirably. If it ain't broke, don't fix it. Given I don't have anyone placing restrictions on my language choice and I've got reservations against C#, I don't see any reason to pick it up. As far as I can tell, Python with C extensions should fix the development problems that I have had with C++, and work better with my programming style to boot.



Trimming out some of the Java rambling, that's my reasoning in a nutshell. The third reason is the most important one; I think I will enjoy developing in Python, Lua and C more than C#. When it comes down to it that's a very important reason to choose a language.

For any C# fans out there, please correct any faults in my reasoning. I'm not exactly "well versed" in the good points of C# and can be convinced by a strong enough argument. As it stands, I'll put my time into learning more Python, trialling Lua and revising C.
Sign in to follow this  


5 Comments


Recommended Comments

Having also an intense hatred for Java, I can tell you that C# (which I do use extensively) feels absolutely nothing like it. The fact that "everything is in a class" IS a bit weird at first, but it's not a big deal (also, C# has "static classes" which are basically collections of static (global) functionality).

Basically, don't hold the sins of Java against C#, it's a very pleasant language to use. It's nice working on it at home, because I don't feel like I'm wrestling with C# like I always seemed to be with C++.

However, your second reason is pretty valid - C# really needs the .net runtime to shine. I know MONO has a good chunk of it implemented, but I'm not sure how much...the .Net runtime is a fabulous collection of functionality - the way it handles strings is something that I'm generally a fan of, and the class reflection functionality (which lets you programmatically get information about classes, class members, functions, etc) allows for some truly elegant systems.

But, if you're doing cross-platform work (especially while developing on a mac), I would *DEFINITELY* hesitate recommending C#.

The third reason is also somewhat valid - it's the reason Mop of Destiny was done in C++ and not in C#..."familiarity." If you're comfortable with a language, use it. But if your goal is to learn a new language to hopefully be able to work faster, C# should be high on the list (excepting, of course, your second rationale).

Again, because you're cross-platform (or, at least non-Windows), C# is likely not the way to go. But for Windows code development, I will never willingly use C++ in any of my spare-time projects again. With C#, I generally feel like I'm working on my GAME. With C++, I feel like I'm writing a ton of low-level code.

Share this comment


Link to comment
Quote:
Original post by Drilian
The third reason is also somewhat valid - it's the reason Mop of Destiny was done in C++ and not in C#..."familiarity." If you're comfortable with a language, use it. But if your goal is to learn a new language to hopefully be able to work faster, C# should be high on the list (excepting, of course, your second rationale).

I can't say I'm familiar with Python. I've been using it for the last half year or so, but I'd be lying if I said I'm now a wizard at it. I have been extremely impressed with how quickly it was to learn and implement things though. I haven't yet implemented any C extensions either, so I cannot objectively say how hard that is. However I used to be adept at C and it's something I've been able to switch back to time and time again.

So from that perspective, I could put C# high on my list, except that 1) I'm concerned about Mac compatibility and 2) I'm happy with Python.

Quote:
Again, because you're cross-platform (or, at least non-Windows), C# is likely not the way to go. But for Windows code development, I will never willingly use C++ in any of my spare-time projects again. With C#, I generally feel like I'm working on my GAME. With C++, I feel like I'm writing a ton of low-level code.

I'm hoping to get the same benefits by using either Python or Lua as the main language. I like low-level coding to an extent, but looking at the code for the games I've done before there's surprising little of it required. The main game loop is pretty straightforward. The tricky stuff is all the game algorithms and some of the GUI code (like font libraries), and that's prime material for high level languages.

Share this comment


Link to comment
If you're interested, you might as well take a look. Especially with your admitted bias against Java (though imo Java should have a bias against it). C# is like Java, but in the same way PHP is like C++. The syntax structure tends to be the same, and some of the core ideas but in practice they're pretty different. And if anything, C# is increasingly drifting from its initial implementation that was much closer to Java.

The main difference I've seen is that Java was designed in a lab. C# was designed to be 'Java without all the bullshit'. Events are there and don't require unwieldy anonymous classes. Generics work properly. Functional style programming is increasingly viable (but admittedly still unweildy). Ints have one type. Operators can be overloaded to do things more naturally. Extension methods can be used to extend or adapt things in the real world where one needs to.


As for C# on macs, I don't know. I looked at mono a few years ago. By all accounts it's made great strides to get all of the 2.0 and 3.0 stuff there. When I looked, it was pretty complete as far as getting things done, it was just 'slow'. Y'know, everything was there, but everything that was current 2-3 years previous. (again, by all accounts mono is near current now).

But that's for content. The CLI tools were complete, and most impressively, I could literally take an EXE from windows, move it to my linux box and it would run. The promise Java made from the start and (in my experience) has only really come close to recently. So portability is there. Your only concern I think is how much mono has 'caught up with' current .NET.


But in the end I think you might just not like C#. I have a gut reaction to python. Always makes me think of perl and vomit in my mouth a little. Is it rational? Not at all, but I can't bring myself to use it.

Share this comment


Link to comment
All your arguments but the last are flawed. The last of which is an opinion, a preference and cannot be approached.

1) As noted C# is not at all like Java now. It has better and cleaner support for reflection, functional and generic programming not counting the much more elegant library implementation and underlying type system. These alone allows you to write cleaner more succinct code. Note that I am not much of a fan of C# but acknowledge that it is a good language when compared to other things like C++ and Java.

2) If all you are making is a game then there is nothing that the .NET library will provide that the Mono will not. Mono is already caught up to the 3.0 version of the language and is even ahead of .NET in terms of a feature that will be more helpful to a game developer, which is intrinsics for SSE type support. Mono used to be fairly slower (but byfar not as slow as python) but has now posted recent speed gains.

Now in choosing Mono one must weight the cost of its requirement. The distribution of mono is not as ubiquitous as .Net on their respective platforms. However you can turn a negative to your advantage by stepping your game up so to speak. By making a game where the cost of acquiring mono is much less than the benefit or value gained from playing your game implies you created a game that most find quite appealing. This means that your game will be good enough that people will want to talk about it. The windows demographic will then help you obtain a larger share of the Mac and linux people than you otherwise would have, though I dont think the revenue gained here will make much if an impression on your balance-sheet.

Indeed if the game is good enough you could consider marketing opportunities such as association with the Mono people as a noteworthy example of a mono targeting application and downplaying the fact that it also runs on .NET (this may well result in the Mac, linux making a more sizable dent due to the effects of hype).

This of course is all hypothetical since you seem certain on Python and since at the end of the day its the game which matters and not where it runs and what it was written on.

Share this comment


Link to comment
Thanks for all the replies. It's helping inform me about the issues.

I'm convinced now that my linking of C# to Java is irrational based on my current ignorance of the language. I won't let that be held against it. I am still a little biased against strongly object oriented langauges for structural reasons, but I'm sure I'd get used to it if I got strongly into c#.

Quote:

Now in choosing Mono one must weight the cost of its requirement. The distribution of mono is not as ubiquitous as .Net on their respective platforms. However you can turn a negative to your advantage by stepping your game up so to speak. By making a game where the cost of acquiring mono is much less than the benefit or value gained from playing your game implies you created a game that most find quite appealing. This means that your game will be good enough that people will want to talk about it. The windows demographic will then help you obtain a larger share of the Mac and linux people than you otherwise would have, though I dont think the revenue gained here will make much if an impression on your balance-sheet.

Indeed if the game is good enough you could consider marketing opportunities such as association with the Mono people as a noteworthy example of a mono targeting application and downplaying the fact that it also runs on .NET (this may well result in the Mac, linux making a more sizable dent due to the effects of hype).

While having to use Mono might not be a show-stopper, this seems like a very sizable negative to me if I plan on going professional. If I am providing a demo or selling a game, I want my potential customers to go through as few hoops as possible to get their product. Every single additional step is a percentage of sales lost. Getting users to download what is to them a strange new library just to run a game demo would be a big disincentive to trying it.

The Mac gamer demographic is one that I'm planning on going after. From what I've read, the Mac market is actually very lucrative for indies (well, "lucrative" relatively speaking.). There's a Mac culture of buying good little creative apps, and the lack of regular game support is a plus.

Quote:
This of course is all hypothetical since you seem certain on Python and since at the end of the day its the game which matters and not where it runs and what it was written on.

I'd say I'm currently close to being sold on Python, but it's not certain. I'm willing to be convinced. However I'm currently more aligned with going with Python. I've started using it, bought a couple of decent books, and have been eyeing off some good development tools. I'm still open to switching to another development language, but I need to be convinced that it will serve my needs better than Python with. Otherwise, with the knowledge I currently have, I will go with my first choice.

Share this comment


Link to comment

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