Lua x XML

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua x XML

Luiz Henrique de Figueiredo
Does anyone know of a technical critique of XML and possibly a
comparision with Lua (as a data language)? Thanks for any pointers!
--lhf

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Matt Campbell-4
Lua is similar enough to JSON (JavaScript Object Notation) that I think the articles and blog posts on XML vs. JSON apply equally well to XML vs. Lua, except in one area: Unicode. Whereas JSON requires that the UTF-8 encoding be used, Lua leaves this issue up to the application.

Matt

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Robert Raschke-2
In reply to this post by Luiz Henrique de Figueiredo
> Does anyone know of a technical critique of XML and possibly a
> comparision with Lua (as a data language)? Thanks for any pointers!
> --lhf

Phil Wadler has a very good page summarising lots of XML resources
(http://homepages.inf.ed.ac.uk/wadler/xml/).  He also co-wrote "The Essence of XML"
(http://homepages.inf.ed.ac.uk/wadler/topics/xml.html#xml-essence).
But nothing specifically on Lua.

Robby


Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Evan Wies
In reply to this post by Matt Campbell-4
My colleagues and I recent had a discussion comparing JSON vs XML vs Lua vs YAML (and some others).  It was a complex
conversation because we had multiple, disparate needs even within our small organization.

The one part where Lua was at a disadvantage was for web applications.  Every modern web browser can handle JSON and XML
natively.  So if one were to go to Lua, they'd always be converting Lua->JSON or Lua->XML.  [Perhaps this isn't so bad
since most web apps have to convert SQL results from their server-side representation to JSON already.]

In the end, we choose XML for our log output due to the ubiquity of tools and libraries for dealing with it (even with
Lua).  But we continue to use Lua extensively for configuration and scripting.

To that end, we also use Ruby for scripting since there is a huge library base compared to Lua.  But, we often load our
Lua-based data + scripts into it (the raison d'etre of RubyLuaBridge).  For example, we easily replaced ActiveRecord's
YAML configuration file with a Lua file -- the advantage being we can use the same database profiles in Ruby, Lua, and C
(via Lua).

-Evan


Matt Campbell wrote:
> Lua is similar enough to JSON (JavaScript Object Notation) that I think
> the articles and blog posts on XML vs. JSON apply equally well to XML
> vs. Lua, except in one area:  Unicode.  Whereas JSON requires that the
> UTF-8 encoding be used, Lua leaves this issue up to the application.
> 
> Matt
> 


Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Mark Hamburg-4
The downside to JSON from what I've seen is that it has no way to summarize
namespaces. Lua could presumably use a local variable to do this.

The downside to Lua is that it doesn't provide any way to guarantee that it
is executing "straight line" code -- i.e., that there aren't loops that
could result in a denial of service attack.

Mark



Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Mark Hamburg-4
One downside to XML v both Lua and JSON is that XML has trouble mapping into
conventional data structures -- e.g., is that element a property of the
parent or a sub-element? One can represent data structures in XML -- though
it's a bit awkward with respect to dictionaries -- but there isn't a natural
mapping from arbitrary XML back to standard data structures.

Mark



Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Javier Guerra Giraldez
On Fri, Mar 7, 2008 at 1:36 PM, Mark Hamburg <[hidden email]> wrote:
> One downside to XML v both Lua and JSON is that XML has trouble mapping into
>  conventional data structures -- e.g., is that element a property of the
>  parent or a sub-element? One can represent data structures in XML -- though
>  it's a bit awkward with respect to dictionaries -- but there isn't a natural
>  mapping from arbitrary XML back to standard data structures.

this is an inherent drawback of XML itself, not of any
library/language/implementation.

IMO, it's important to decide at the start of any use of XML what are
you using it for. if it's for 'structures' an E4X-like API is great.
if it's for 'documents' a SAX-like API will do nicely enough.  if it's
for 'all under the XML universe and beyond' you're stuck with
abominations like DOM.

which remembers me... i've never published my L4X module anywhere...
it's waiting until i get some 'inspiration' and add the ability to
modify the data (IOW, in deep freeze).  should i publish it somewhere
as is? (read-only but quite nice to use)

-- 
Javier

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Peter Cawley
In reply to this post by Mark Hamburg-4
On 07/03/2008, Mark Hamburg <[hidden email]> wrote:
>  The downside to Lua is that it doesn't provide any way to guarantee that it
>  is executing "straight line" code -- i.e., that there aren't loops that
>  could result in a denial of service attack.

You could potentially write code to check that loaded code is
"straight line" by dumping the loaded code and quickly looking over
the opcodes. If there are any JMP by a negative offset, FOR or TFOR,
then it isn't straight line.

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Luiz Henrique de Figueiredo
> If there are any JMP by a negative offset, FOR or TFOR, then it isn't
> straight line.

There's also recursion... And it's harder to spot.

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Chris-41
In reply to this post by Luiz Henrique de Figueiredo
One of the biggest problems I have personally run into with Lua for
data description is that the compiler chokes on medium to large data
sets.  Maybe I was doing something wrong but was getting some error
about running out of constants when I was just trying to load a bunch
of objects into a table.

CR

Reply | Threaded
Open this post in threaded view
|

Re: Lua x XML

Dustin Bruzenak
In reply to this post by Luiz Henrique de Figueiredo
Lua/JSON/YAML are great for configuration, internal harvesting of data, and data communication between processes in the same application. This is largely because they're simple, fast, pragmatic, and easily represent complex data structures.

XML is good for communication with multiple applications written by a number of vendors. Valid, well formed XML is a wonderful thing to have when integrating at the edges of two complex information systems.

In general, I'd use Lua/JSON/YAML for internal development, configuration, and communication and then expose an XML interface at the edges and as a file format for the rest of the world to consume and modify.

Luiz Henrique de Figueiredo wrote:
Does anyone know of a technical critique of XML and possibly a
comparision with Lua (as a data language)? Thanks for any pointers!
--lhf