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.

In what cases are what scripting languages better than others?

All answers are appreciated, please provide a description, and describe in what cases the language excels in.

(Remember, one language per answer)

share|improve this question
add comment

closed as not constructive by Tetrad Jan 22 '12 at 1:51

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

14 Answers

Lua is widely used in the game industry. From independent games (Aquaria) to AAA titles (Civilization).

The core reason? I would say because it is easy to learn and easy to incorporate into your games. But the same could be said for Python, I'm sure. Scripting, in general, isn't difficult. I think the real reason you should go with Lua is because it's proven which results in much more resources out there for you to learn from.. If you feel like experimenting with something outside of the norm then I would start messing with another language.

share|improve this answer
7  
Lua is very popular because it provides "meta language" features. You can implement object-oriented structures, or pure procedural functions, etc. It has a very simple C interface, and gives the engine developer a lot of flexibility in the language itself. –  Karantza Jul 14 '10 at 19:34
3  
I'm not convinced python would make a good choice. The C bindings for python are much more geared towards extending python with C, then embedding python in C. –  SpoonMeiser Jul 14 '10 at 21:09
5  
From what I've heard, Ĺua also has good runtime performance when compared to other scripting languages like Python. (and it has full support for closures - a really nifty feature if you ask me..) –  thbusch Jul 14 '10 at 21:15
1  
I've been using Lua extensively in my games. It has been fantastic (and yes, closures and coroutines are wonderful.) Strongly recommended. –  ZorbaTHut Jul 16 '10 at 14:08
1  
Actually Civilization IV uses python... –  Emiliano Jan 20 '11 at 12:56
show 4 more comments

Squirrel

Squirrel has an interesting history. It was built after a game architect had issues with Lua's unpredictable garbage collection, and crazy everything is null even if it doesn't exist.

Squirrel is the sripting language used in Left 4 Dead 2. The API is very lua-like (Squirrel's author loves Lua's design).

So Squirrel is an awesome language as it's kinda 2nd generation Lua. It took the good ideas and removed the annoying eccentricities.

Same from Lua:

  • coroutines
  • tables and metatables
  • dynamic typed
  • lots more

New to Squirrel:

  • classes
  • arrays
  • regexs instead of Lua's match syntax.
  • C/C++/Java/C# style language instead of Pascal/Delphi style.
  • lots more

Squirrel's primary disadvantage is it's not Lua. Lua is much more widely used. But if that's not an issue Squirrel is an easy win. However, often the language's popularity is useful feature in itself, so the decision is not so clear cut.

share|improve this answer
add comment

That depends on the game and its target platform.

A game that runs 100 non-player characters (RTS games) has different needs from a game that runs just 2 (Street Fighter). A game that runs on a PC has different needs than a game that runs on a console.

Lua is popular

GameMonkey is used by several teams. It's faster than Lua and better at threading.

Python has been used in several games.

JavaScript is a possible option as you can download JavaScript engines. There are more JavaScript programmers than any other type of programer.

There are also specialized languages.

SCUMM has been used in several adventure games and it is particularly suited to those games.

share|improve this answer
    
Javascript is a really good idea. I wonder why it doesn't seem to have had traction in this space? Any ideas? –  cflewis Jul 14 '10 at 20:09
    
JavaScript does have traction. Unity uses it. So does Wolfire Games for their engine. –  A.A. Grapsas Jul 14 '10 at 20:19
    
Two engines really don't make traction. I'd guess the reason it's only a recent development is that there haven't been many good JavaScript interpreters prior to Mono and V8. SpiderMonkey isn't exactly something you look and say "Yes, I want my game to be that fast and lean and stable!" –  user744 Aug 15 '10 at 17:15
add comment

V8 Javascript from google.

PRO's :

Quite easy to use

Constantly getting better

Powerful and flexible

Others As many mentioned , javascript is a common programmer tool. Adding it to my games has opened far more people who feel capable than other languages. It also supports a huge amount of casting and conversion to save on work for the programmer, also makes it really easy to use, works well with STL.

Possible CON's :

Documentation can be confusing Its really not the best.

Examples Often a web of weirdness. Lacking in solid simplicity, it comes across as way higher level than it is.

Templates Sometimes these are hated on, or avoided.

SDK Codebase size Generated code size may be consider bloat.

share|improve this answer
    
One con for me was the size. If you're building a simple/casual game then the v8 engine is quite large, and may even be many times larger than your entire game. –  Zack The Human Aug 15 '10 at 18:12
    
True, but as a standalone .lib file is that a big concern? It simply slots in next to your SDL, or your lua. If you meant generated code size, well i haven't tested how big it is but thats not a bad point. –  underscorediscovery Aug 15 '10 at 21:03
    
I meant the generated code size. I suppose it's not THAT large considering the size of most games today. –  Zack The Human Aug 15 '10 at 23:22
1  
Tested, Default shell.cc with latest SVN clocks in at 1.441 MB bit.ly/9DNn8J. While this seems quite hefty, most library's needed to do anything else (networking, graphics) will add to that just as dramatically. A side project of mine with v8, phoenixGL, ENet, bunches of boost, and a lot more code inside the solution (like compression, encryption, gui libraries, awesomium) clocks in at 2.5 MB in visual studio 2008 - And zipped in a "release" build weights in at 861 KB. For me, that is not all that bad. On certain platforms i could see it being troublesome - not for most though :) –  underscorediscovery Aug 16 '10 at 9:07
1  
Ive used V8 a few times before in my projects. IMO Javascript is the most ideal language to use for game scripting. The event-based nature and prototype-based objects makes everything so easy. :) –  Stephen Belanger Nov 14 '10 at 11:53
show 2 more comments

For completeness sake, another option is mono-script, which allows you to use the Novell implementation of the .NET framework for scripting. It's what Unity uses. Here's another page about embedding mono in your application.

The Mono framework is faster than most (perhaps all?) of scripting languages out there because it's not interpreted, and because there's a layer between the compiler and the instruction set, it allows you to program in a variety of languages including C# and dialects of Python, Lua and Javascript.

I'm not sure if it's free on all platforms however.

share|improve this answer
2  
Note that if you're doing console development, JITing code is apparently out of the question because you can't mark data pages as executable. The IL it has to be pre-compiled to the target platform. –  Jeff Jul 15 '10 at 18:06
add comment

Personally, I found AngelScript (see link below) much easier to bind to C++ than Lua when I was choosing a scripting language for my own project. (I actually wrote a small wrapper library for it to make it even easier to use, at the cost of some flexibility.)

http://www.angelcode.com/angelscript/

That being said, I suspect Lua has a few advantages that make it compelling for commercial games developers:

(a) It's more mature and widespread than AngelScript

(b) Its syntax is easier for non-programmers (AngelScript is very C++-like)

(c) It has a smaller footprint than AngelScript (at least as far as I recall)

If you're just writing a hobby project, though, I'd say that AngelScript's at least worth a look.

share|improve this answer
add comment

Scheme

Well, guile specifically.

With guile you can have your own DSL (Domain Specific Language) just for your game. Once you get used to the parentheses and prefix notation, scheme is heaven to work with.

If you're going to use guile in a serious game, I would wait a couple of months until the 2.0 release as that will include, IIRC, an Ecmascript interpreter as well as the current scheme one. You can also expect to see large speed improvements.

share|improve this answer
add comment

This depends on what you actually need it for. As David points out, Lua is very popular, although one game developer noted to me that he wasn't entirely sure why. I think its lightness is a common reason, but at that this point, I would expect a lot of people use Lua because that's become the de facto standard. It seems best for very lightweight modification.

For a more fully-fledged approach, I'd say Python is the right choice. Civ IV used it to decent effect.

share|improve this answer
add comment

You should choose a scripting language that has stable and well-supported bindings to your game's primary development language. If you are writing your game in C or C++, then there are pretty solid bindings available for Python and Lua. If you are writing your game for the .NET platform (using C# or another language), then I highly recommend using either IronPython or IronRuby. Both are complete language implementations that leverage Microsoft's Dynamic Language Runtime (DLR), which provides excellent performance and very tight integration with the .NET Framework. Interoperability between C# and IronPython/IronRuby is pretty smooth these days, especially with the introduction of dynamic callsite binding in C# 4.0.

share|improve this answer
add comment

Choosing one scripting language over another is dependent on your specific requirements.

Some of the options you have to choose between could be:

Speed of the interpreter - if the feature of scripting is solely used i.e. by developers to script static behaviour, then speed and a fully-fledged and extendable API may be the most important aspect. I had some good experiences with LUA there.

Easy to learn, accessibility - for a content-/leveldesigner it may be hard to learn more complex scripting languages (depends on the background) to generate dynamic behaviour. In that case, the use of easy to learn (i.e. commonly used) and well documented languages could be more appropriate here. JavaScript or Python could be a good solution here.

Workflow integration - if you have a specific production pipeline with already existing tools, it could be a bad idea to use a language which seems to work best for a given case if the other tools are working with a completely different one. This is especially valid if you have several programmers working on the different tools. In that case, it could be more efficient to use the "not quite fitting" language.

share|improve this answer
add comment

If you're working on a title for Windows and writing managed code running on top of the Common Language Runtime (CLR) - let's say e.g. in C# - I'd suggest you have a look at integrating (Iron)Python as scripting language.

In my experience, Python is very easy to teach to non-programmers/designers. It is even easier to pick up for developers since it essentially reads like pseudocode. Being dynamically typed is just one of the aspects that help to get people with little to no prior coding experience up and running fast with the language.

In addition to the language being easy to learn and powerful, the CLR and language teams at Microsoft (Anders Hejlsberg, Eric Lippert, Mads Torgersen, Jim Hugunin et al.) have done some great work in exposing compiler and runtime features via the new Dynamic Language Runtime (DLR) in .NET 4, making interoperability between statically typed code and dynamically typed code much more straightforward. From what I've seen and tried so far, boilerplate code is reduced to a minimum. It'll keep your codebase clean and maintainable.

You can utilize this to keep the friction between the scripted parts of your game and the engine very low. Having both run within the same VM will also make it possible for the runtime to optimize more of your code during execution.

share|improve this answer
add comment

The answer very much depends on your environment. I am currently working with Unity, so I use a mono based language (in my case C#, but Javascript and Boo are also options). The answer depends entirely on your specific circumstances.

share|improve this answer
add comment

ActionScript is a hybrid dynamic/static typed language used to create Flash games, which can be widely distributed on the web. It is fairly well supported with libraries like Flixel, FlashPunk and Box2d.

share|improve this answer
add comment

If you have an existing team that will use the scripting language or a lead (level)designer that will use the scripting, then go with whatever their language of choice is. They will be spending their time with it, so they should be catered to.

[grain of salt] If you don't have anybody or plan long term, then roll your own. yes, writing a compiler and/or interpreter for a scripting language might take a week or two, but in the long run the flexibility will pay of many times. Just don't go to far astray and reinvent brainfuck. [/grain of salt]

share|improve this answer
    
I would write an interpreter or jit-compiler in haskell for sth like lisp/scheme or bash or python or lua or erlang (anything without its standard libs) in one or two days. I would not suggest to write an interpreter in i.e. C++ or Java, as long as it is not for interpreting sth lisp like. But that was not the question, anyway. –  comonad Nov 18 '10 at 0:33
    
I think the question was more geared to the pros and cons of scripting languages, not really how to decide which one to use. Still helpful I suppose. –  Michael Coleman Nov 29 '10 at 2:00
add comment

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