S&box Gameplay & Content

Garry’s Mod’s Lua versus S&box’s C#

Facepunch Studios have announced that their upcoming sandbox game will be powered by C#, rather than following in the footsteps of Garry’s Mod modding with the Lua language.  This has raised some controversy within the modding community – some negative, some positive.  A lot of people are happy at the prospect of having the power of C# in their hands, but at the other end of the spectrum, people are unhappy about having to learn something new and seemingly complicated.  Lua versus C# is a popular topic, and here’s my take on it.


Why C#?  Lua was working just fine!

It’s no secret that Garry himself no longer endorses Lua.  Lua has some obvious differences which are unordinary or inconsistent with other programming languages, and in the grand-scheme of things, these differences are counter-productive, especially for beginners who are just learning to program.  Just read that blog by Garry and you’ll see what I mean.  For experienced programmers, these inconsistencies just cause headache and anger.  The type of anger that makes you want to break your desk.  The one that bothers me most is Lua’s not equals operator.  In every language I’ve ever touched, this operator is depicted with a simple !=.  Some smart guy behind Lua decided it would be wise to change this operator to ~=.  Makes complete sense, right?

To be fair, these inconsistencies aren’t all that bad, and the mass popularity and usability of Lua justifies coping with it.  I’ve experimented with a variety of scripting languages, and Lua’s documentation, popularity, wide selection of libraries, and ease of implementation puts it near the top of the list.  Sure, there’s a lot of hate on this language, but it can’t be denied that it’s an excellent choice for many uses.


Why not both?

Yes, there will be Lua in S&box.  There are many libraries developed in C# with the purpose of implementing a Lua scripting environment.  XLua is my personal favorite, honorable mentions include MoonSharp and NLua.  It will literally be as easy as dragging and dropping a dll, and BOOM, there’s your Lua.  If you’re thinking outside the box right now, you already know that this means other scripting languages, i.e. Python, can be implemented just as easily.

I talked a little bit about this subject in one of my videos: Can you BHOP in S&box?


C# is so complex!

C# itself is not complex.  It’s modular, readable, and the syntax is easy to understand.  If you’re a GLua developer, the one thing you should really be concerned learning is object-oriented programming.  I heavily suggest you run a google search on that term, and begin learning OOP right away, especially if you plan on modding S&box.  OOP can be applied to a wide variety of languages, and it’s a very valuable skill to have, especially in the eyes of employers.  Learning OOP will do you a lot of good, and learning C# alongside it will do you even better, as C# is currently one of the most widely used languages in various aspects of software development.


C# Guides and tutorials

There are many resources on the internet for learning both OOP and C#, it’s only a google away.  In the future, I will personally be providing support and tutorials for modding S&box with C#, and you’re invited to stick around!