[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reasons for a Web Developer to use Lua?
- From: Marc Balmer <marc@...>
- Date: Wed, 16 Mar 2011 10:09:51 +0100
Am 16.03.11 08:21, schrieb steve donovan:
> On Tue, Mar 15, 2011 at 11:10 PM, Chris Babcock <cbabcock@asciiking.com> wrote:
>> Lua may not have the obvious library support that Python does, but the
>> basics are there and the APIs tend to be pretty stable.
>
> Sputnik really is so much more than a Wiki, although it takes a little
> effort to get used to [1]
>
> The idea of versioned data as Lua tables is very powerful.
>
> The big Lua web effort has always been Kepler, which is responsible
> for many of the library goodies for Lua (many of the 'canonical'
> libraries come from this project).
>
> My favourite from the Kepler stable is Orbit [2], although Chris might
> not like its default ORM (but this is not compulsory; the Sputnik
> versioned storage can be used as standalone libraries)
>
> There is a chicken-and-egg problem: wider use of Lua in the web space
> requires more libraries, and these get written when there is a need
> which is larger than an individual developer's itch, i.e. when there
> is wider use of Lua. In terms of flexibility and performance, it's a
> natural fit otherwise.
FWIW, here is how we use Lua for Web-based applications (actually the
backoffice for the arcapos POS solutions, www.arcapos.com, is realized
this way):
We have a small core in C, a Unix daemon process, that runs in the
background and communications with a webserver (lightttpd, apache) over
FastCGI. The C core handles authentication and authorization. It uses
Neotonic ClearSilver as a template engine. ClearSilver functions are
exposed to Lua.
For every user that logs in, a Lua state is created, a cookie ties a
session to a Lua state. In the GET or POST request we have one field,
'op', which is the discriminator to decide what operation is requested.
The operations are implemented in Lua. Upon startup, Lua code can
register functions for certain ops, and the function will then be called
by the C core:
http://whatever/app/index.html?op=some_action
The Lua code would then register a function to be called for some_action:
register('some_action', function ()
-- do work
end)
We are quite happy with this, it is reasonably fast and quite secure (of
course I omitted many details here ;)