AngelScript vs Lua

Discussion in 'Game Development (Technical)' started by Pogacha, Sep 16, 2009.

  1. chanon

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    468
    Likes Received:
    0
    Just thought I'd share my current experiences with Lua:

    I'm actually in the process of developing the next generation of our internal game development framework and Luabind is a big part of it.

    I also considered AngelScript since I also like C++ style syntax and typed languages, but my conclusion was that it wasn't proven enough.

    I chose Lua because nothing else was as proven, portable, and had as good performance as Lua. Also Lua is somewhat standard so any programmers I hire might already have experience in it.

    Python looked too heavy-weight and it's performance isn't as good as Lua.

    I looked at Google's V8 Javascript engine a bit too but it looks like it is tied to certain platforms (meaning it might not run on iPhone or PSP for example). I also couldn't make sense of its binding mechanism (I probably didn't give it enough effort.)

    Luabind's binding syntax may look a bit alien, but after a while it feels natural. I also wrote some simple macros to make it easier.

    And I never used boost before too, always thought it would be too messy to deal with. But after I decided to use Luabind I decided to embrace boost and have found some very useful stuff in it. For example I now use boost::intrusive_ptr a lot which really eases using std containers to hold objects.

    To avoid memory leaks in Lua, just let the C++ side handle creation/destruction. My objects are created and held with smart pointers in C++ and lua only uses references to them.

    EDIT: Also wanted to say that if I had unlimited time, I'd want to implement my own scripting engine too. My feeling after using Lua/Luabind is that I feel pretty relieved that I can leverage the work of other people who are pretty good at this stuff instead of having to take time doing something so far removed (writing a robust scripting engine) from actually making money.
     
    #21 chanon, Sep 18, 2009
    Last edited: Sep 18, 2009
  2. chanon

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    468
    Likes Received:
    0
    That's looks pretty cool :) Have no idea what the boxes with the numbers are for .. I guess you click on them and the details are displayed in a dialog. Thanks for sharing! Always cool to see a different paradigm of doing things.
     
  3. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    There are really not many languages that can interface directly with C++. I blame C++.
     
  4. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    I realize everyone has different opinions on what makes the "perfect" scripting language, but seriously... I have a hard time believing anyone could really find a real, nail-in-the-coffin, production efficiency-related reason to not use Lua.

    The language is simple as hell to learn, C++ binding is relatively painless (and I don't even use SWIG or Luabind), it's efficient, the documentation is good, and the shipped product history is there. You can use it for entity scripts, config files, save data, GUI widget methods, and more. What more could you ask for?
     
  5. Mattias Gustavsson

    Original Member

    Joined:
    Aug 10, 2005
    Messages:
    669
    Likes Received:
    0
    No no, the point wouldn't be to make the "perfect" scripting language, or a "better lua". It would be to make a simpler scripting language tailored to the task in question.

    Example: say there is a need to do simple scripting of dialogs, and there are non-programmers who need to do it. It would be reasonably easy to make a "script"-language like this (though this example is so simple that it could be argued that it is data-definition rather than scripting, but it serves to illustrate and it's a fine line anyway).
    Code:
    [10032]
    <Bond>Do you expect me to talk? 
    <Goldfinger> No, Mr. Bond. I expect you to die. 
    
    [28452]
    <Bond>What would it take for you to see things my way? 
    <Galore>A lot more than you've got. 
    {1}How do you know? @28457
    {2}I wouldn't be so sure... @28459
    {3}Shaken, not stirred. @28458
    
    [28457]
    <Galore>I don't want to know. 
    
    And this would both be easier for a non-programmer to get their head around, as well as less risk of making weird mistakes, than if you'd have to do it in free-form lua scripting. This "script" language obviously couldn't be used for any purpose, and that's exactly the point - it's custom made for the task at hand. If we would need, say, an AI-scripting language, we'd do something different, but also custom made.

    Of course, sometimes you DO need a full-fledged generic scripting language - and in that case, it makes perfect sense to use Lua or AS. But it can also make sense, in that case, to NOT use a scripting language at all - it might be that the C++ IDE is a better fit if you need a scripting language with that level of complexity.
     
  6. lobotony

    lobotony New Member

    Joined:
    Mar 10, 2008
    Messages:
    37
    Likes Received:
    0
    I've grown pretty fond of declarative constructs in Lua. Something like:
    Code:
    Dialogue
    {
      "10032"=
      {
        "Bond" = "Do you expect me to talk?" ,
        "Goldfinger" = "No, Mr. Bond. I expect you to die." 
      },
      "28452"= 
      {
         "Bond" = "What would it take for you to see things my way?",
         "Galore" = "A lot more than you've got.",
         1 = {"How do you know?", 28457},
         2 = {"I wouldn't be so sure...", 28459},
         3 = {"Shaken not stirred.", 28458},
       },
       "28457"=
       {
         "Galore" = "I don't want to know."
       }
    }
    
    where Dialogue is a function and the rest is a single table as input parameter. It has it's quirks with the trailing commas, ordering and quoting, but IMO it sufficiently resembles an XML like structure so that non-coders might not be too intimidated.
     
  7. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    I don't disagree with you, I'm just thinking in terms of the original post and how there might be a bit more due diligence being applied here than is actually necessary.

    Rolling your own vs. going off-the-shelf is the kind of tradeoff we deal with quite often. The difference here is that custom scripting systems tend to service very specific needs that are generally considered corner cases. There's a reason the same scripting languages are recommended all the time; the good ones are robust enough to handle everything at more than acceptable levels.

    jcottier's system is a good example of such a corner case, but that wasn't Pogacha's original question. Between Lua and Angelscript, I think most of us would have a hard time finding a programmer who could demonstrate a measurable increase in productivity all due to the fact that one scripting language had a syntax closer to C++ than the other. They're all extremely easy to learn* and they all work, so just pick one :)

    *Well ok, except for Perl :)
     
  8. luggage

    Moderator Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    I wouldn't give that to a non-programmer!
     
  9. lobotony

    lobotony New Member

    Joined:
    Mar 10, 2008
    Messages:
    37
    Likes Received:
    0
    luggage,
    I get your point, but I've mostly lost my respect for people that are overwhelmed by the slightest technical issues. If a programmer has to have an eye on project management and develop a sense for design and aesthetics in order to get their job done, then a non-techie can try to match up some braces and place a few commas.
     
  10. luggage

    Moderator Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Good luck with that then. Let us know how it goes when you hand it to someone who is non-technical.
     
  11. Pogacha

    Original Member

    Joined:
    Jan 21, 2005
    Messages:
    605
    Likes Received:
    0
    Thanks chanon.
    Your statement about not being proven enough actually scares me a bit ...
    I don't believe it can be a problem after so many years of development but I would like to know a little more about AngelScript stability ...
     
  12. chanon

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    468
    Likes Received:
    0
    Right.
    I just couldn't find a good list of games that use AngelScript.
     
  13. Bad Sector

    Original Member

    Joined:
    May 28, 2005
    Messages:
    2,742
    Likes Received:
    5
    What is a non-programmer doing near scripts? To write scripts you must know about programming.
     
  14. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    I have to agree here that there is a limit to how far you can take the "make scripts easier" line of thought. For a lot of designers/artists who can't script, the problem isn't that the syntax is too difficult but rather they're brains are just not wired up for thinking that way. Sometimes you work with creative types who have great ideas but can't think the logic of the mechanics through to save their lives. That's why we have technical artists/designers :)

    If your scripts are usable to your technical staff, I say you're golden.
     
  15. Mattias Gustavsson

    Original Member

    Joined:
    Aug 10, 2005
    Messages:
    669
    Likes Received:
    0
    Not all types of scripts requires programmers (but it could be made so by using a general purpose programming language instead of a custom made one).

    In the case where you have a type of script which requires programmers: why use scripts at all, when you could just do it in code?

    I'm not saying there are no cases which require general purpose scripting languages - I can think of many reasons, like enabling modding for example, or taking advantages of the loose coding style of type-less languages - but I think it is often the case that us programmers just jump for the generic solution, which technically solves the problem at hand, without giving full consideration to its impact on things beyond the code. IMHO.
     
  16. MFS

    MFS New Member

    Joined:
    Feb 28, 2007
    Messages:
    314
    Likes Received:
    0
    The most common reason (IMHO) is runtime reloading. No need to rebuild code -- that can save a lot of time.

    Generally though, if an artist/designer can't cope with the scripting language, it's lost more than 50% of its value for me. All of the scripting languages I've worked with in the mainstream industry were rolled in-house by core technology groups and artist friendly. The time savings can be immense.
     
  17. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,385
    Likes Received:
    0
    Yes.
    I work on a AAA game that took 20 minutes to do a full rebuild (with all the libs).
    Sad, when you had to change a critical .h ;)

    JC
     
  18. Mattias Gustavsson

    Original Member

    Joined:
    Aug 10, 2005
    Messages:
    669
    Likes Received:
    0
    Yes, that's a reason, but often it is possible (and preferable) to just use Edit-and-continue (but not always). Btw, it's amazing how often I've seen scripting implemented without runtime reloading :rolleyes:
     
  19. MFS

    MFS New Member

    Joined:
    Feb 28, 2007
    Messages:
    314
    Likes Received:
    0
    Except edit-and-continue isn't available on all compilers and even in VS it has lots of limitations. Much like jcottier, the last project I worked on in the mainstream industry (before I left for the lands of teh indie!) took 30 minutes for a rebuild --- on a dedicated set of build servers:( I really don't miss that!! :D

    As for scripting languages without runtime reload, I'd agree and consider that to be straight junk. Seriously, why bother? I've never worked on/seen a commercial game that used a scripting language without runtime reloading FWIW.

    Edit: To be fair, 30 minutes was for a full rebuild although typical link times were still several minutes. To be even more fair, it was a 4 platform build process.
     
    #39 MFS, Sep 21, 2009
    Last edited: Sep 21, 2009
  20. Bad Sector

    Original Member

    Joined:
    May 28, 2005
    Messages:
    2,742
    Likes Received:
    5
    And if you're going to add dynamic reloading, you might as well add in-game editing. Nothing like typing "edit <script>" in an in-game console and editing the script while the game is running at the background.

    And its dead easy to put this if you already have dynamic reloading (hint: you don't have to use some custom GUI library for the editor, just use whatever your OS is providing).
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer