Thoughts on C#

Now Microsoft is trying to spread out C# with Xamarin. As like always, Microsoft products never been amused me.

C# appeared in around 2000. Actually C# 1.0 was almost my frist “proper” programming language. I thank to Microsoft for C# because I could start programming relatively easier. But, my entire programming life was a bit screwed due to C#. Because I was wanting to make a “game” which is a soft-realtime shooters. It was my first try of game making in 2004 with a bit hardcore genre called “Bullet Hell”.

That’s the reason why my programming life had been a bit screwed. C# has GC. Fully automatic, tracing, stop-the-world garbage collector. And that means your game will lag shortly sometimes, and there’s no way to fix it. I was screwed.

In my first try, I never could figure out why my game running on powerful 64-bit desktop CPU performs worse than 8-bit game consoles. Because shooting games on consoles never showed such lags. They didn’t even in Microsoft DOS age.

Of course it’s because of GC. The GC at the time was really hell. It wasn’t even generational at first. Now I know what the problem is, but was not at the time.

Now I just think C# was not appropriate to my goal at the time. I was just idiot enough.

My second try was a 3D shooter about in 2008. That was fine. But I chose C# again, and that’s my (same) second mistake. The game worked pretty well, and again, I got a lot of help from C# because some of Softimage | XSI content pipeline supported C# API, so I could relatively easily export them into my game. (of course that’s because Softimage has been acquired by Microsoft once). Anyway, again, I had to be suffered by GC lag. At the time, C# had been equipped generational GC, but it wasn’t helpful at all. And it degraded my desire to develop the game. And finally, I decided to learn C++ eventually to develop games properly. (and of course, I didn’t have to “write” a new content pipeline tools from scratch if I was using C++)

Early version of Unity also has been appeared around the time. And I was disappointed in Unity because it was based on C#. I didn’t go further.

After that, I got learned a lot including C and C++. Now I know that the core problem is GC. In theory, it’s possible to build real-time aware applications using GC, but in reality, I never seen something that is truly real-time with GC. And over 10 years of suffering made me to become hostile to GC’ed platform.

One day, Unity started to gain a lot of traction, and I just ignored it. Because I knew that GC will be a problem at the end. GC shipped with Unity was just same thing that was shipped in .NET in 2004. It’s not even a generational one. For now, Unity has fully generational-GC which is same with one shipped in .NET 2008, and expected to have incremental-GC eventually. But would it really help? I am not very positive.

This is why I don’t welcome the “Xamarin” hype made by Microsoft. Xamarin is .NET.

C# is deeply GC based language. It’s impossible to run C# without fully automatic GC. Which means an app must stop the execution momentarily to collect garbages eventually sometimes. Therefore, destiny of Xamarin is already set. Whatever you make, it will have some problem with GC wherever such stopping can be problematic. Even some server people hate GC due to its lag. (AFAIK, server-side GC is very rare but it’s a real headache once it actually happens because usually you have no good way to deal with them) If you’re going to make some fancy animation, you’re screwed.

Another my hatred about C# includes lack of const-correctness, lack of Algebraic Data Type, friend-type, insane complexity of P/Invoke. And all of these stuffs will prevent you to be a better programmer.

Anyway, many people will choose Xamarin. Because they’re ignorant like me in 2004. Because this is the only option to some people who are just like me in 2008. Anyway, I hope people to reconsider using C# and Xamarin.

Like what you read? Give Hoon H. a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.