Thread Tools Display Modes
03-26-09, 02:06 AM   #1
shiin
A Fallenroot Satyr
Join Date: Feb 2005
Posts: 23
Efficient LUA code?

Since I am currently refactoring my old addons, I was wondering wether there are some guides out there on how to write efficient LUA code (i.e. the basic do and don'ts).
  Reply With Quote
03-26-09, 03:03 AM   #2
Zyonin
Coffee powered Kaldorei
 
Zyonin's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 1,443
I don't know about guides to efficient Lua code, however if you have an IRC client (they are easy to find and you may have one without even knowing it), then go over to:

irc.freenode.net

and join the channel:

#wowace

Then you can talk code with the various crazies over at WoWAce. Otherwise find some good examples of efficient code (Tekkub's mods are a good example, then again I am just a novice coder myself), take em apart and see how the author has put it together.

Another IRC channel is:

irc://irc.freenode.net/WoWUIDev
__________________
Twitter

Last edited by Zyonin : 03-26-09 at 03:05 AM.
  Reply With Quote
03-26-09, 04:04 AM   #3
Eggi
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 10
Don't focus on efficiency as it is absolutley not important if your addon uses a few kb more memory or a little bit more processor time. It is much more important that you write clean code.
Only if some parts of your addon are called very often (e.g. OnUpdate) you should try to avoid doing unnecessary things there.
  Reply With Quote
03-26-09, 05:13 AM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Eggi View Post
Don't focus on efficiency... It is much more important that you write clean code.
In many cases, the two are mutually exclusive.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-26-09, 05:15 AM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Heres a couple of links:

http://lua-users.org/wiki/OptimisationCodingTips
www.lua.org/gems/sample.pdf

The main sources of performance issues I've noticed are lack of table reuse, another way to help is to make your Options only load into memory when needed.
  Reply With Quote
03-26-09, 08:14 AM   #6
Zergreth
A Fallenroot Satyr
 
Zergreth's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 24
I disagree with you, Eggi. Efficiency is one of the most important things to me. If everybody would code addons the way you say it, without looking at efficiency, then that would probably mutate into some large pile of badly used memory and processing time. I have to agree with Torhal's post, too. If you want clean code, you can as well go for efficiency, since efficient code is usually clean.
  Reply With Quote
03-26-09, 07:44 PM   #7
Tekkub
A Molten Giant
 
Tekkub's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 960
Efficiency and clean code go hand in hand. You can write "beautiful" code that runs like ****, or amazingly fast code that is impossible to read. The real skill is doing both :P
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Efficient LUA code?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off