Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I plan to do a fairly small game development project as a single programmer. I have read that alternatives to C++ such as C# or integrating Lua scripts is more time and effort efficient in development.

Why is C# easier to work with (if it even is), and what benefits does Lua offer (as well as why)?

share|improve this question
2  
Whether it's easier to work with C++, C#, Lua or any other language depends on who you are and what you're doing. The general rule for which language to use is "whichever one you want that has the libraries you need and can run on the platforms you want to target". If you're interested in why scripts are used (which can also be written in Python or other languages) there's a question on that. I'm voting to close this question as not a real question because it's incredibly vague. –  Jonathan Hobbs Sep 14 '12 at 6:58
2  
I am sure there may be a way to turn this question into something more specific and constructive, but generally "which technology should I use?"-type questions are considered off topic since they're all very specific to what you're doing, and there's already an answer for why scripts are used. –  Jonathan Hobbs Sep 14 '12 at 7:18
    
@JonathanHobbs Agreed on all of the above. Seems like OP is asking for guidance on the purposes and strengths of specific languages, which is not obvious to someone new to gamedev. Someone may read forums/blogs saying "Java is ideal for indies, Minecraft was written" or "C++ is the only way to go" or "Lua is the best scripting language" and have no context for judging these opinions. C# further complicates since it's the primary development language for some commercial games, but is also a common scripting or tools language. Maybe it's out of scope for SE, but it'd be good to see this covered. –  michael.bartnett Sep 14 '12 at 17:26
add comment

closed as not a real question by Jonathan Hobbs, bummzack, Laurent Couvidou, Ali.S, Byte56 Sep 14 '12 at 14:34

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

Choose a language based on what you are personally interested in using. especially since this is a single-person project. You could write the whole thing in C++ and be fine. You could also write the whole thing in C#. You could also use something like Corona or Love2D and write the whole thing in Lua.

A common pattern is to write low-level and speed-critical game code in C++, and wrap this up into a higher level API with a scripting language. Lua is a common choice because it has a lightweight runtime and flexible syntax. The reason that an integrated scripting language is more time/effort-efficient is because you don't have to spend the time recompiling your game engine. In fact, you could feasibly load game scripts while the game is still running, constantly tweaking them as they game runs.

C# with Mono has made headway as a scripting language thanks to Unity. C# will generally have faster execution time overall since it's JIT-compiled, but these things always depend on the use case.

Since C#/.NET/Mono is so fast, it's also common for people to just write their whole game in C# using frameworks and libraries like XNA, MonoGame, or OpenTK. You can also use a language that targets .NET IL code and write a lot of game logic in a non-C# language such as IronPython, IronRuby, F#, or Boo. If you go the route of C#/.NET, it's often viewed that a scripting language integration is not necessary. C# on its own is very expressive, and you could always use a more dynamic language like IronPython to write higher level game logic.

You can also consider Java (as your "native" language, it's not very good for embedding). The same principle of targetting the VM from C# (C# vs IronPython vs F#, etc.) works with Java (except you're looking at Scala and Clojure).

C# Advantages

  • Garbage collection frees you from concern about memory management

  • The standard library is very very large. Not Java-large, but that's probably a good thing.

  • Linq makes data processing pain-free.

  • Lambda expressions standard part of the language

  • XNA is a very nice framework

C++ Advantages

  • As fast as you can hope to get.

  • Explicit control over memory.

  • A large variety of game libraries are implemented in C++.

  • The lingua franca of commercial games (good "career language" to get employment as a game programmer)

  • Explicit control over your memory cannot be overstated.

Lua Advantages

  • A very flexible language. Although no support for "classes" right out of the box, tables are a rich mechanisms for rolling your own.

  • Relatively easy to integrate into an existing game engine (compared to say, Python or C#/Mono)

  • A very small core library and runtime.

  • Fairly standard, used by a lot of big game companies in addition to UnrealScript and Python.

  • LuaJIT is supposed to be really really fast.

Other scripting languages in the same vein as Lua

These also see common use as scripting languages.

(Anyone with more experiences with other scripting languages or the ones listed here, please edit.)

share|improve this answer
1  
Thanks for making this a community wiki (since we all know this question didn't belong). –  Byte56 Sep 14 '12 at 14:38
add comment

Lua wouldn't be the most efficient language to use. It's got lots of things you will find it hard to get used to (like array indices that start from 1 and the requirement to handle many different argument setups in each exposed function, as well as lack of IDE function-name-guessing support). It might work well if you can memorize things easily.

The reason people say things like "using Lua is more efficient than using only C++" is because Lua is a scripting language so you don't have to wait a lot of time for it to recompile when you change something. Well, the same is true for a C++ project if you don't use too much of STL (limit yourself to string, vector and map and/or unordered_map) and don't use Boost at all and don't use any engines which have lots of those headers included. You can most probably enable a header dump in compile options to see what is included. This is how you can do it for MSVC.

Now for the C++ vs. C# problem: people often pick C# as if it's going to save their life but unfinished projects and all sorts of other problems happen either way. For this choice, it's all about what you like to do - whether you like to be closer to metal and fight memory allocation correctness (C++) or have all sorts of things handled for you, if you can endure the extra typing, annoying exceptions and compiler errors appearing in place of simple features like using an integer like a boolean (C#).

If it's a project you need to finish quickly, I'd recommend looking at the toolsets available, picking the best (no matter what programming language it works on) and forgetting about the language dilemma.

share|improve this answer
add comment

C# and Java are managed languages. They take care of memory management for you. Though the main selling point is that they offer much more support when it comes to standard libraries compared to C++. If you're alone and you're making a simple project, then these languages will offer you portability and ease of development. Developing in C# and Java is much easier than C++ unless you need your code to perform perfectly. The lack of const types, or template metaprogramming makes developing complex code much easier under C++. Benchmarking C++ is much easier aswell. It's all up to you. As a one man project i daubt that you need this kind of code quality and the minimal performance gains you'll get by writing custom memory allocation and other such hassle. C# and Java are perfect candidates.

Now the reason you use LUA is the same as using any other scripting langauge. You want to make your program do something without recompiling it. Scripts let you do that. You can tweak objects in game like AI or hotspots without waiting 10 minutes for your code to compile. This is why scripting is said to be speeding up development. However, this is for big projects, if you're making a game by yourself then between pressing "Run" and seeing your game window you'll be waiting maybe 30 seconds. Implementing scripting is an interesting excercise, but probably not necessary in your case.

Other alternatives would be HTML5/CSS3/JavaScript and Flash. For HTML5 all you need is a browser preferably Chrome or Firefox with the Firebug plug-in. It's a scripting langauge like LUA, so you get instant feedback, you can alter your code on the fly, etc. Besides you learn alot about web technologies. The technology is still brand new, so it has its problems. Flash is more mature, still faster and works, but requires an IDE.

share|improve this answer
add comment

The difference is just in how hard it is too learn, C++ is one of the hardest practical languages out there.

Lua is a purely embedded language and the API is customized by every game, it's easy to mod a game which is using Lua, but making your own game using Lua isn't. It only pays of when you have a lot content.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.