Why C# all of a sudden?

Started by
30 comments, last by Styves 6 years, 6 months ago

For 20 years C++ was the recommended standard language, especially in the gaming industry. Mostly because it is fast and powerful, inheriting most programming language standards you can possibly think of.

There were a lot of languages to come and go, and some stayed.

I.e. Java, since 1995 the most hated of them all (at least how I experienced it).

Considered really slow, JIT is shit and its strong OOP rules and type safety is disabling the programmer or for whatever reasons. Causing (among others) a lot of religion flame wars between believers.

C# is basically a Java copy but with some changes to the base architecture like support for pointers, tuples, structs and more, extending the idea of Java.

Now this isn't a Java/C# comparison or discussion! C# wasn't "well" received at the beginning, either.

However, in the last two/four years I noticed that in general and in this forum C# suddenly got a big popularity boost, including but not limited to gaming industry.

I am neither against nor for C#, I get paid for writing code in a lot of languages, but

What changed? Why is C# or JITs (or for whatever reason Java and C# were hated) acceptable, now?

My personal interpretation for a very long time was Unity and possibly the name "C"# causing a popularity boost among young programming beginners causing old hands to rethink their stance.

Or is it just computers getting more powerful?

Advertisement
For 20 years C++ was the recommended standard language, especially in the gaming industry.

In 2001, the C vs C++ debate was still alive and well, albeit fading. In 2008, when I was working on AAA games, the console compilers still struggled with more sophisticated C++ idioms and standard library code (containers etc) were not necessarily bug-free. "C-with-classes" code was still quite common.

C# is basically a Java copy but with some changes to the base architecture like support for pointers, tuples, structs and more, extending the idea of Java.

Of course it's drastically easier to write graphics code with those changes to the base architecture. You're glossing over them but look at Java based GL code and tell me that's not awful.

However, in the last two/four years I noticed that in general and in this forum C# suddenly got a big popularity boost, including but not limited to gaming industry.

Game industry: Unity. On a slightly longer timeline, tools code has been moving towards C# for a long time. It's not much more complex than that.

Outside of games: You're late. C# has seen widespread use in client software development for a long time.

Apart from Unity code, there's relatively little C# game development happening to be honest. There's some adoption of it in the mobile realm, as it's a nice language for shipping across all of the major mobile and desktop platforms all at once.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

I.e. Java, since 1995 the most hated of them all (at least how I experienced it).


Also the most popular of all, at least across programmers in general.

C# wasn't "well" received at the beginning, either.


As far as I can tell it was very well-received in the Microsoft/Windows development community, where they don't need the power of C++ and Java was not a great alternative due to various legal and philosophical issues.

However, in the last two/four years I noticed that in general and in this forum C# suddenly got a big popularity boost, including but not limited to gaming industry.

I am neither against nor for C#, I get paid for writing code in a lot of languages, but
What changed? Why is C# or JITs (or for whatever reason Java and C# were hated) acceptable, now?


Computers kept getting faster, and it became increasingly likely over time that the full low-level control that C++ gives you was no longer strictly necessary for game development purposes.

Unity finally provided the proof of that (with the caveat that the engine itself uses C++; but for the end game developer, that's not important.) And that proof allowed previously hesitant developers to take the risk.

There's also another factor, which is that C++ had a serious competitor in 2D and web gamedev world in the form of Flash + Actionscript. As those technologies got phased out, and with HTML5 slow to pick up the slack, a lot of those developers moved over to Unity and C#. Their games were already proven to run on a VM so this was not a big leap - but it did perhaps mean these people were sharing the same tool as the 3D game developers and no longer ignored by the more traditional gamedev community.

I.e. Java, since 1995 the most hated of them all (at least how I experienced it). Considered really slow, JIT is shit and its strong OOP rules and type safety is disabling the programmer or for whatever reasons. Causing (among others) a lot of religion flame wars between believers.

Java is a memory managed language, very similar (nearly identical) to C#, but has been poorly implemented, not just performance of its memory manager, but even actual bugging of it, such as memory acumulation over time, uneffective or even absent memory moving and pooling, too long sweep visits of manager etc.

Is it over? Do not know and I do not think.

On the other hand, C# has been an extremly well implemented mem-managed language on Windows NT platform.

C# applications will even outperform C++ aplications 90% of time, since C# will move memory, while static fixed heap allocations of a c++ process will never do so.

In other words, you will have to write top professional c++ aplication to outperform C#, while it is true that ideal c++ will outperform C# clone of instructions always.

C# is thus very popular in game development, it is performative, production safe (c++ can couse leak bugs that can even dump entire projects), fast to work, and it is popular even over the difficulty in actual game development it has, since DX has to be wrapped to be used safely in C#, as GPU can be accessed only thrugh c++ libraries (there are already C#/CLI modules that does the wrap, even official ones such as XNA, but XNA dated out with income of newer DXes).

CLI is the actual bridge between memory unsafe and memory safe modules of a process- what you have stated about pointers in C#, is not entirely true, pointers are in CLI, or unsafe blocks in C# that are not reccomended.

So yes, C# is so great that even gamedev industry desires for it, even if it has the one (difficult) obstacle mentioned.

While JohnnyCode's numbers are clearly made up and has some substantial factual errors, his comment is reflective of common beliefs.

When it comes to tools work I've seen Java stuff since it was introduced around 1995, and I've seen C# tools since about 2003. More recently I've also seen a ton of JavaScript tools relying on NodeJS and similar.

Several game engines have used it for scripting, not just Unity. The Sims 3 engine used C# for all gameplay scripting, and it incorporated C# about the same time Unity did, about 10 years ago.

When it comes to tools work I've seen Java stuff since it was introduced around 1995,

I too have cried why Java did not shine over. Not even JASP -java active simple pages (as http active serving documents), are not coded at all! Through willigant atempts.

But, I accepted it, Linux is a free, and for free, you cannot get service, maintenance, support, guarentees..... etc. But I still thank to working Linux still, it just cannot compete with payed players :) !

Unity and XNA and now Monogame are probably the big pulls for C# (And mono, Unity is technically some old decrepit version of Mono). It's also a delightful language to program in compared to C++, depending on what you're doing, of course. At my day job, we use it for all our unit tests, because it's much faster to write, and cleaner than C++, so it's easier to write unit tests and easier to grok what the the unit test is supposed to be testing.

C# is a really powerful and expressive language that can easily interop with other .NET languages as well as C. It has really good development tools. Performance wise, it's not as fast as optimized C++, but for a lot of use cases it's more than fast enough (faster than many alternatives) with some serious stability and security benefits. It's typically very hassle-free compared to Java and many other solutions on Windows, which is the platform of choice for most gamers and probably also game devs (though this seems to be changing rapidly).

Java was designed with various academic values and best-practices in mind, where C# was designed as a more practical language for real world scenarios. For example, C# has unsafe and P/Invoke integrated into the language. This makes it very good at interfacing with existing code, but is arguably unclean. C# also has both value types and reference types with the same syntax. This can be confusing and is arguably also "ugly", but extremely practical when trying to interface with native code and/or trying to control memory layouts. For things like vector math, vertex arrays and tile maps, this can make a huge difference.

C# has been embeddable since an early age, making it easy to use as a scripting language. It's very easy to use for tools that interface with whatever engine you are using. The overall cross platform support is probably worse than Java etc, but it's good enough on all platforms that are relevant for games.

Outside of games: You're late. C# has seen widespread use in client software development for a long time.


Not just client. It's been popular in server side for at least 10 years now (between "web methods", WCF, and lately ASP.net web APIs).
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

The C# language is also fast moving, while it started as a poor mans Java in C#1 it has grown and now Java is trying to play catch up (Apart from the huge drag that Oracle owning it causes). C#6 was a great improvement and added some nice language features and C#7 brings proper tuple manipulation and some basic pattern matching. Even the introduction of Linq raised it far above Java. Most people see Linq as about enumerable types but the reality is that it is more like the computational blocks in F# and can be used for any type that provides a Select/SelectMany pair of functions (Bind and Map in other languages)

This topic is closed to new replies.

Advertisement