13

Will a game written in C# have any speed issues after long periods of play, like for 24 hours at a time? I'm specifically talking about a 2D RPG similar to old Final Fantasy or Dragon Quest games. I know that languages like Python will slow down too much, curious how C# would stand.

edit: programs I write are a lot like a termite-infested tree :)

@jimmy - thats the entire point of this. I'm working on a small FF clone to improve my coding

Matt
  • 131
  • 1
  • 4
  • 7
    " speed issues after long periods of play" - regardless of language, that sounds like memory leaks, or just plain 'ol bugs.. – Mitch Wheat Mar 13 '10 at 01:20
  • 1
    @Mitch Wheat - Isn't it possible that the way the garbage collector works would affect it? If it's not very good and causes fragmentation, it's conceivable that after 24 hours things will slow down. – Edan Maor Mar 13 '10 at 01:27
  • 1
    @Edan : that would be a bug in the garbage collector. – kervin Mar 13 '10 at 01:30
  • if you know that your programs are a lot like a termite-infested tree, you could try working on that instead of writing programs that will be slow regardless of what environment you run in. In particular, if your coding is sloppy, writing in C++ will cause more memory leaking and thus worse performance than writing in a higher level language like C# or Python. – Jimmy Mar 13 '10 at 01:35
  • @Mitch Wheat: IIRC, the hash tables in Python's ubiquitous dicts can slow down after heavy key turnover. – Daniel Newby Mar 13 '10 at 02:02
  • @Mitch Wheat - Not necessarily. At least on embedded systems, I know that some garbage collectors have issues with fragmentation (for performance reasons). I don't know if any languages running on Windows have these issues as well, but they might. – Edan Maor Mar 13 '10 at 09:14
  • You do not know "that languages like Python will slow down too much". Plenty of games are written entirely in Python including their low level (e.g. rendering) routines and do things more involved than the games you cite on modern hardware. – MarkR Mar 13 '10 at 22:31
  • @Matt It certainly is. Take a look at this... https://stackoverflow.com/questions/39387698/simple-and-fast-real-time-graphics-for-c-sharp-computer-game-winforms/39388029#39388029 – WonderWorker Oct 05 '17 at 15:51

6 Answers6

11

Yes, it is. Take a look at XNA. There are already some games written in C#.

Charlie Salts
  • 13,109
  • 7
  • 49
  • 78
2

I'd take a look at this Channel 9 video posted years ago from Eric Lippert

Eric Lippert - Have you noticed a performance hit in .NET?

It's a great watch if you're wondering about comparative performance. Computer hardware has advanced a great deal more since then, but the concept hasn't changed, C#/.Net can have excellent performance if you're using it correctly.

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • 1
    Wow, that's an oldie. I ran into Charles on the bus today; hopefully we'll get some more Channel 9 videos done one of these days. – Eric Lippert Mar 13 '10 at 03:20
2

If code slows over the course of its execution -- and by that I mean doing the same thing takes longer -- it's a sign that memory is not being managed correctly. I don't know what you mean about Python slowing down, but I don't have much experience with it. It's possible that some game or graphics libraries don't handle memory correctly, which could cause performance to suffer (and eventually crash). But closing the app and restarting would fix any issue like that -- and surely you'd have a save feature if a user was to play for 24 hours?

To answer your question, correctly written C# will not slow down if you play the same game for too long. (But neither would correctly written Python code, or any other language).

Ian Henry
  • 22,255
  • 4
  • 50
  • 61
2

The high-level game logic could definitely be written in Python. In fact it's quite common to use a "slow" scripting language to allow more freedom to the game designer. In practice the lowest levels of the game (like the hardware interface / drivers) are written in C. Everything else in between is open for debate depending on what type of performance you require and what type of hardware it will be running on.

karunski
  • 3,980
  • 2
  • 17
  • 10
0

The XNA Game kit for XBox 360 uses C#...

kwcto
  • 3,494
  • 2
  • 26
  • 33
-1

The .NET rewrite of Quake:

http://www.codeproject.com/KB/mcpp/quake2.aspx

Alex
  • 1,997
  • 1
  • 16
  • 31
  • Excellent example of the potential of .NET performance! But, that port was actually done with managed C++ and not C#. – Paul Sasik Mar 13 '10 at 02:21
  • 1
    Yeah that's right, Paul. At the end of the day we have a some IL and a managed application. The actual language used to get there shouldn't matter too much. – Alex Mar 13 '10 at 11:11
  • @Alex, Managed C++ also accepts using unmanaged native libraries. Part of your program could be managed and the other could be unmanaged that's what is special about Managed C++. So it is not exactly as VB .NET and C# that are purely managed assemblies with IL. – Lzh Jan 12 '12 at 23:42