Need scripting advice for my project

Started by
26 comments, last by Diodor 19 years, 7 months ago
Although I generally agree with the use of Lua in this case, I would defend TinyXML as I have always found that to be a solid library for what it does and not really 'flaky'. For projects without embedded scripting languages, TinyXML is a great way to read and write structured configuration files with minimal effort. XML is not entirely without support; Age Of Mythology is one game that relies heavily on XML files, making it easy for mod developers.
Advertisement
Quote:Original post by Kylotan
Although I generally agree with the use of Lua in this case, I would defend TinyXML as I have always found that to be a solid library for what it does and not really 'flaky'. For projects without embedded scripting languages, TinyXML is a great way to read and write structured configuration files with minimal effort. XML is not entirely without support; Age Of Mythology is one game that relies heavily on XML files, making it easy for mod developers.


I honestly haven't tried TinyXML. I've used libXML2 though, and from my experience with it, it was a slow parser and quite flakey at times. If I have the need for XML I'll definitely give TinyXML a try. As of yet though, I haven't found anything (at least for gaming) where XML gives me a pure advantage over something else. However, for structured online content XML is kinda hard to beat :).
---michael bernsteinmichael@simoniac.com
Quote:Original post by thesadjester
I've used libXML2 though, and from my experience with it, it was a slow parser and quite flakey at times. If I have the need for XML I'll definitely give TinyXML a try :).

I have use libXML2 quite extensively, and IMHO it is plenty fast for data loading, and has never fallen down, except when my code is at fault. However, the flexibility with which it has been defined makes it very easy to write bad code, and many users never really seem to learn the fast and simple ways to parse xml data.

I have to admit, that while I use xml for most of my games, it does not make a good final runtime solution, mainly because the extra disk space used by all those tags, etc. slows down file access and parsing. I noticed the Ogre engine has gotten around this by using xml files during development, and then using a tool to convert them to binary files for shipping with the finished product. This seems a bit of a hack, and I would advocate using binary files and a simple editor app throughout the process, but this, of course, doesn't allow text editing, although it is very fast.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I wanted to bring this decision on my team to a close, so I googled for "XML lua versus" and found 3 useful sources of information about the matter. Here are the three links and important excerpts I've copied from the documents.

"GDC 2004 - Lua in the Gaming Industry Roundtable Report"
http://www.gdconf.com/archives/2004/burns_jon.doc

"A question was posed regarding using Lua or XML for data definition. The general consensus was that Lua is much more compact and readable than XML."

"XML is good for describing small sets of data and web-related data, and it was suggested that a team could use XML as a meta-language to express game data in binary, which would be good for cross-platform development."

"Most agreed it is much easier to find XML-savvy editors than Lua editors."

"Most developers heavily experienced with Lua said Lua is a language that developers can learn in about 10 minutes and that non-programmers can pick up at a fairly quick pace."

Scripting Programs with Lua - Gallaudet Research Institute
http://gri.gallaudet.edu/~cvogler/ research/data/yhslug021304.pdf

"Some projects that use Lua: Baldur's Gate, Escape from Monkey Island, MDK, Grim Fandango. Mostly used to control AI and behavior"

"Lua for data description

Lua is ideally suited to describe data and configuration files.
XML is all the rage, but Lua has three advantages over it:
- Much easier to use than an XML parser
- Much smaller than the monstrous XML libraries out there
- The third one will become apparent in this talk"

"Processing Sequence Annotation Data Using the Lua Programming Language"
http://www.jsbi.org/journal/GIW03/GIW03F016.pdf

"To avoid having to program in 2 languages simultaneously, the ”document object model” method allows a program to access XML data as a structured variable on-memory. This is the same as our approach with the data warehouse."

"In addition, while XML usually describes a well-formatted static data schema with rigid tags, an active research project sometimes requires modifying and adding new tags on demand. Although XML can provide consensus annotation data file formats, the use of such tags would yield conflicting differentiations from the original XML schema."




I can say that after doing this research, I am officially pro-Lua. I would like to see any documents that can find the inherit advantages of XML over Lua (especially in gaming applications), but I have not found any such material.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

I was thinking about going witu xml and &#106avascript my self, however, lua has been proven many times like was said earlier, it can be used for all sorts of things, its syntex is easy to learn and theres tools for binding it with C++.

Hehe, but the coolest thing about lua that most of you guys may not know, is that it was used to manage the oxygen mixtures in one of the space shuttles! If Nasa can use it, I think I can ;)

All together though,IMO: with any project, you should use what best fits your needs and not use something just because its the trendy thing to do.
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
Off-topic, but while we're talking about software systems in space I'd like to point out that the international space station runs on Linux. :D

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

Awesome debate. I think I have a few pro xml arguments to add as it seems to be defended the least.

Just to clarify, the debate can't be about lua vs xml directly because we all know that lua is a scripting language, xml is a data format definition and storage language. (has been said but some of the posts seem to have ambiguity e.g. touting lua's dynamicness compared to the very static xml, which is true but it is of course possible to use xml with something else (even lua itself) to get dynamic data).

I really like to separate out and define all the components of what I am trying to do. Doing this to data lends itself to using a data definition language (funny thing is that I created my own data definition format before finding xml). If you are using lua for data storage it is hard to 'see' the actual data format that you use. It has to be shown implicitly (through the actual data itself) unless some type of language is used anyway. The power of xml is that you can take a look at a schema and find out what the data should look like. You can validate data against the schema among other things.

I also find it important to have levels of abstraction. For me the biggest reason for using a scripting language in a game environment is to pull game related logic out of C++ (or whatever optimised language you use) and into a simplified environment. I think that using another format for data (xml) is another step in this direction. Xml promotes structure and has rigid guidelines for validity, whereas in lua a dataformat can be dreamt up by anyone and differ in design to the rest of the project.

These arguments as well as the others (tools, etc) are why (for the moment) I will be using xml in my projects.

So in sumary - structure, definition, modularisation.
Quote:Original post by umbrae
Just to clarify, the debate can't be about lua vs xml directly because we all know that lua is a scripting language, xml is a data format definition and storage language.


A subset of Lua can be (and was designed to be) used as a data definition/storage language. That subset is IMHO more readable, less redundant and more powerful than XML.

The more practical level of comparison between the languages involves the available implementations: the lua interpretor and the XML libraries.

The downside of Lua _may_ be that it easier to access XML data from C/C++ than it is to access lua data from C++ (since XML libraries return that data in the form of a C++ object).

Quote:If you are using lua for data storage it is hard to 'see' the actual data format that you use. It has to be shown implicitly (through the actual data itself) unless some type of language is used anyway. The power of xml is that you can take a look at a schema and find out what the data should look like. You can validate data against the schema among other things.


It is just as hard to "see" the format of XML files. But whereas XML asks for yet another language (two actually) to validate the format, in Lua you can just use Lua to validate the data, which, unlike XML Schema is a real programming language, and therefore is more flexible (though perhaps harder to use).

Quote:For me the biggest reason for using a scripting language in a game environment is to pull game related logic out of C++ (or whatever optimised language you use) and into a simplified environment.


For me it is using a sane language. Dynamic typing, REPL, first order functions, closures, hash tables.

This topic is closed to new replies.

Advertisement