[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: The World According to Lua: How To?
- From: "Jasmin Patry" <jpatry@...>
- Date: Fri, 18 Feb 2005 18:37:46 -0800
I've written several medium-to-large programs in Lua, and haven't had
any problems with scalability. It does take some discipline, but so
does writing a large program in C++.
As for the "biggest problem" that you identified, it's easily remedied
with the following:
setmetatable( _G, { __index = function(t, k) error( "accessing
undeclared global variable '" .. k .. "'", 2 ) end } )
I always do this when developing anything non-trivial, and it's saved me
countless times.
Cheers,
Jasmin
-----Original Message-----
From: David Given [mailto:dg@cowlark.com]
Sent: Friday, February 18, 2005 6:08 PM
To: Lua list
Subject: Re: The World According to Lua: How To?
On Friday 18 February 2005 22:11, PA wrote:
> On Feb 18, 2005, at 22:06, Glenn Maynard wrote:
> > I'm not saying one can't; I'm saying one normally does not. Lua is
an
> > extension language; extending is what it's good at. If you're
writing
> > a whole application in it, you'll quickly find out what the
difference
> > is--it's not good at it, and isn't supposed to be.
>
> Perhaps... time will tell... on the other hand... if people didn't
> experiment with Lua in new and weird ways... Lua would still languish
> as an obscure "data entry language" of sort:
[...]
I use Lua as a scripting language, to knock up simple throwaway programs
quickly. The two most complex programs I've written in it are a Makefile
generator --- which works very nicely --- and a C++ preprocessor that
expands
special syntax for our platform. Both of these highlighted Lua's
problems as
an application programming language; basically, it's not scalable. It's
very,
very good at writing *small* pieces of code and very, very bad at
writing
*large* pieces of code. You can get around this with discipline, but
frankly
if I was writing a large application I'd use something else --- Ruby,
perhaps.
Lua's biggest problem when writing large applications is the hoary old
chestnut of misspelt global variables. It's *amazingly* painful not to
be
warned if you misspell a variable name... your program just doesn't
work,
sometimes in strange ways. A lesser problem is the fact that variables
are
global unless specified local, which is the opposite to most other
languages.
Personally, I don't think these are big issues; Lua's not an application
programming language, it's an extension language, and the requirements
are
different. Perhaps one day it would be nice to have a different compiler
for
the VM, whose input language had a different emphasis, but I don't see
it
happening soon. I also don't see Lua's semantics being changed, because
the
existing semantics are too useful for Lua's primary purpose.
--
"Curses! Foiled by the chilled dairy treats of righteousness!" ---
Earthworm
Jim (evil)