Re: [GD-General] Scripting Systems
Brought to you by:
vexxed72
|
From: Brian H. <ho...@py...> - 2004-01-28 22:07:19
|
So I finally am getting around to using Lua "in anger" (i.e. in real
honest to God code), with Nick Trout as my personal coach to see me
through the (one step better than horrible) documentation.
And what I've learned so far is that scripting, while cool in theory,
is really a pain in the ass in a lot of practical ways, most of it
having to do with type checking and basic things of that ilk.
My most common programming errors are simply mechanical:
1. Accidentally typing object:method() instead of object.method() or
vice versa
2. Forgetting that table.foo() isn't called ON the table but WITH the
table, i.e. it's table.insert( t, ... ) not t:insert( t )/t.insert()
3. Typographical/memorization errors:
function object.foo( x, y, z )
....
end
o.foo( y, x, z ) -- oops!
or:
function client.create()
=09local c =3D { client_name =3D "Default" }
=09return c
end
c =3D client.create()
c.name =3D "Brian Hook" -- oops!
or
-- oops, forgot the 'then'!
if c.client_name =3D=3D "Brian Hook"
c:doSomething()
end
Finding these (often trivial) problems requires me to load and run my
scripts, and in some cases I have to get into pretty entrenched areas
of my code (e.g. AI that responds to being attacked, etc.). It really
sucks to load up a game, spend 5 minutes getting a particular
condition to occur, then having things barf/not work because you typed
"nname" instead of "name"...
This is all embedded as well, so using a development environment
doesn't seem feasible (but I haven't looked into them enough to say).
Also, because of the reliance on calls back into my main kernel, I
can't exactly make independent unit tests that run with the command
line interpreter.
Do other languages handle this any better? JavaScript suffers from
the same problems since it is also prototype-based (a la SELF et.
al.).
Brian
|