3 ms·
It's mostly a historical accident, like Python ending up as the data science language. Microsoft XNA used to be a popular indie game framework that used C#. St
by orthoxerox 4y ago
It's mostly a historical accident, like Python ending up as the data science language.
Microsoft XNA used to be a popular indie game framework that used C#. Stardew Valley, Celeste and Terraria run on XNA.
Mono used C#. Xamarin used Mono to create a cross-platform application framework that worked on mobile. Unity leveraged Xamarin to create a cross-platform game engine that worked on mobile, ending up using C#.
Thus, two generations of indie gamedevs ended up learning C# to create games. Then Unity grew a whole lot, so more and more people ended up associating C# with game engines, so as soon as Godot was released people started asking for C# support.
But C# being the language of choice doesn't really depend on specific C# features. It could've just as easily been Lua or JavaScript instead. For example, RPG Maker moved from Ruby to JavaScript when they upgraded to a new engine, again, because their new rendering engine was nw.js, and getting it to run almost anywhere was easy.
- kevingadd 4y agoI'd argue that the availability of value types in C# gives it a leg up over languages like JavaScript for performance-sensitive games work. These days v8 and spidermonkey have incredible garbage collectors capable of incremental/parallel collection so people have been able to ship JS-based games on PC+Console, but when it comes to game scripting it's either languages with value types like C#/C++ or languages with more predictable garbage collection behavior and performance like Lua and Ruby (Ruby especially is popular with Japanese developers, likely because the language originated over there.) C# being possible to mostly AOT compile (some exceptions) is also an advantage over JS for scripting since JS is not particularly efficient to run in an interpreter and many deployment targets don't allow you to JIT code at runtime. Languages like Lua have much better characteristics for those targets since they have high performance interpreters and cleaner language semantics.
- mardifoufs 4y agoI'm completely uninformed about lua, but why isn't it being used more to build games then? I know it's a popular scripting language for games, but are there any engines that mainly use lua (in the same way Unity uses C#)?
- danbolt 4y agoLua very much hit a sweet spot in terms of performance and flexibility for proprietary codebases over the last twenty years. One or two programmers can embed it into an application and expose bindings for designers rather quickly. It’s kind of a min/max of flexibility and engineering work. As engines became larger products, companies often have the resources to make something bigger for game teams. Unreal’s Blueprints, or Godot’s GDScript integrate much more tightly with the engine’s runtime.
- kevingadd 4y agoLua is very widely used despite the fact that Unity and Unreal don't support it.
- runevault 4y agoI don't see this at all. game devs on average want to be closer to the hardware and JS is even farther from it than c# (and c# has added more ways to do things like traditional pointers when you need to squeeze even more performance out). Lua you can certainly make an argument for because LuaJIT is insanely fast.
- aseo 4y agoI don't think game devs on average want to be closer to hardware. Game engine devs, sure; but the average game dev would like to use a higher level language that interfaces to the c/c++ stuff that game engine devs are pushing out.
- orthoxerox 4y agoaseo is right, of course, but even with game engines it depends on the game. Modern hardware is fast enough that you can get away with a lot. Minecraft used to be written in Java, 2D games that aren't Dwarf Fortress can be written in practically anything. If you're an indie dev you usually don't want to strain the hardware with extremely complex models and textures and rendering pipelines, because you don't have the money to produce or source these models and textures.
- deleted 4y ago[deleted]