lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 ----- Original Message -----
From: HyperHacker
Date: 7/5/2010 7:51 AM
On Mon, Jul 5, 2010 at 06:41, Brian Weed<brianw@imaginengine.com>  wrote:
Lua is probably quite fast already even if you only use global
variables, ie, don't bother with locals.

That's been our experience.

We use Lua to script almost all of our games, and we've never once
localized a global (for performance, or any other reason), because it's
not a bottleneck, and we don't waste time "optimizing" stuff that's not
a bottleneck.
Premature optimization is the root of all evil, after all.
I shouldn't answer this, but I will anyway.

It is not always possible to optimize at the end of a project when bottlenecks are staring you in the face. Projects have deadlines and need to ship. Making sweeping changes to optimize areas invalidates all the QA work done to date. Many optimizations are also incredibly dangerous to make and could easily introduce new problems.

That said, a more appropriate approach would be to ask yourself up front if any of the subsystems could become a bottleneck and make the necessary changes early.

In my case, if I know that local variables are MUCH faster than using globals (and they are), I'll use local variables as a "premature optimization". I wrote it right (for performance) the first time, and that means I don't have to revisit that area later.

IMHO.

Josh