Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

Squirrel or Lua for RPG quests, gui and AI scripting?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 NetrickPL   Members   -  Reputation: 116


Posted 13 February 2013 - 08:33 AM

I'm currently making an RPG and everything is going great, I've been working on it for 6 months and I came to point where I need script language for easy writing quests, ai and configuring gui. I don't have time to write a big editor which would allow to create quests etc without scripting.


However, I'm stuck between Lua and Squirrel. Lua is much more used in the industry, but squirrel has nicer syntax to me (c++ like). Both have good c++ binders, oolua and sqrat. Both languages are wery well maintaned, but on the binder side, I found that almost all squirrel binders are abandoned (for version 2 only and now there is 3). Only sqrat is updated for 3, but still it's not that actively maintaned and I'm not sure about it. Lua has a lot of active binding tools.


On the other hand, I heard that lua garbage collection is very bad in terms of performance and it can slow down my application every 30-60 sec. And I need good performance all the time without slow downs. Actually one of the reasons why squirrel was made was to fix the lua garbage collection. However, in lua 5.2 they changed something with garbage collector, but many people say that it is still bad...


Based on your experience and knowledge, which language should I choose? I really don't know. If you know a language better than these 2, tell me about it.

Edited by NetrickPL, 13 February 2013 - 08:34 AM.


#2 Kylotan   Moderators   -  Reputation: 3338


Posted 13 February 2013 - 08:41 AM

I heard that lua garbage collection is very bad in terms of performance


Lua is much more used in the industry


If the performance is good enough for 'the industry', why wouldn't it be good enough for you?


Squirrel is a perfectly good language in my limited experience but you have to decide what is right for your situation. Personally, if unsure, I would always go with the better known option. Voyages into lesser-charted territory usually come unstuck when you encounter a problem that nobody else has encountered because the community's too small.

#3 JTippetts   Moderators   -  Reputation: 8598


Posted 13 February 2013 - 08:50 AM

I've never used Squirrel, so I can't really say anything there.


As far as Lua goes, it is possible that you can run afoul of the garbage collector, but there are plenty of ways around it. The collector is fairly flexible; you can disable automatic garbage collection and specify manual collection steps to be run when you desire. Also, Lua provides locals that are implemented in a register-like fashion, so by careful usage of locals and just general all-around thoughtfulness, you can reduce the generation of garbage to an acceptable happy medium.


I use Lua for the main guts of my game, Goblinson Crusoe. Certain aspects of it (scene rendering, pathfinding, picking, etc...) are implemented in C++ and exposed to Lua, but the main loop and all of the logic are Lua. I have had upwards of a thousand AI objects operating concurrently (back when it was a point-and-click Diablo-clone, not the turn-based thing it is now), and the performance was more than acceptable. Just be careful about the generation of unnecessary garbage, and you're probably going to be fine.

#4 Hawkblood   Members   -  Reputation: 724


Posted 13 February 2013 - 09:06 AM

Sorry I suggested anything.

Edited by Hawkblood, 20 February 2013 - 01:22 PM.

#5 Eden-san   Members   -  Reputation: 113


Posted 13 February 2013 - 09:28 AM

I can safely say after using Squirrel for almost 6 years that it is a very solid choice as a scripting language.
The language in itself makes a lot of sense which makes it easy to learn, has all the features you'd expect, and no GC (HELL YEAH!).

Edited by Eden-san, 13 February 2013 - 09:30 AM.

#6 bollµ   Members   -  Reputation: 354


Posted 13 February 2013 - 11:15 AM

what about angelScript? I'm using it right now i my engine, and it's fantastic for C++ binding. you don't need to mess with metatables or anything of the sort.


It's really easy to bind and most (if not all) C++ abstractions can be bound directly with angelscript.

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

#7 Flimflam   Members   -  Reputation: 657


Posted 13 February 2013 - 03:09 PM

Lua isn't really that slow. For what you're interested in using it for, it would be more than a fine choice. 

#8 BGB   Crossbones+   -  Reputation: 1554


Posted 13 February 2013 - 07:10 PM

probably either Lua or Squirrel would work.

usually if a person is dealing with lots of GC performance issues, it probably means they are doing something wrong.
except for certain types of tasks (like using scripting code to write parts of a 3D renderer or the physics engine), raw performance of a script-language isn't usually a huge issue.

in my case, I am using a custom scripting language.
probably hardly mature enough to recommend it to anyone else, but granted I am prone to writing most of my own code (and was largely unaware of many of the scripting languages which existed at the time, ~ 10 years ago, having had been only really exposed to Python and Guile).

Squirrel looks vaguely similar to my language, so that is interesting to me at least.

side notes (my language):
the syntax in my language is much closer to ActionScript3 mixed with elements of C and C#. in its present form, it is mostly using static/manifest typing (though dynamic typing is also supported, and still often used), supporting either AS3 or C# like declaration syntax, and using a C#-like collection of core types. it has a GC, but tries to minimize memory leaks and has value-type structs/classes (value-classes are like structs, but with methods and copy-constructors and similar), as well as "delete", and things like strings and vectors are built-in types, ... (and for 32-bit x86, currently has a basic JIT).

package/import and class declaration syntax works more like in AS3 though (comparable to namespace/using in C#).
technically, the language design was more of a grab-bag though (neither minimalism nor elegance were significant goals).

loading is typically either directly from source, or from bytecode (where VM bytecode may be embedded inside DLLs or SOs via an embedded WAD-like container).

would probably need considerably more work though to compare favorably with more mainstream languages: for example, making everything faster and more robust, having a more feature-complete set of core libraries (vs a half-assed J2ME knock-off), ... but, for my uses, it is mostly ok.


Edited by cr88192, 13 February 2013 - 07:11 PM.

#9 bonch   Members   -  Reputation: 129


Posted 19 February 2013 - 09:48 PM



Lua and Squirrel would both work fine, which is kind of a wishy-washy answer, I know. Since you're already leaning toward Squirrel, use Squirrel. If you want more info, you might be interested in this article discussing the advantages that come with Squirrel over Lua:




That said, they're both excellent scripting languages for embedding, and none of Lua's quirks are a dealbreaker. Just quirks.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.