Talk:Lua/Tutorial

Your Two Cents
As all things wiki, this is a living document. I encourage you to improve it. While it is new (or undergoing any significant changes), you may want to share your ideas, here, on the Talk page. Thanks for your contributions! Deeb (talk) 00:31, 31 May 2012 (UTC)

On performance, loading data, etc.
Someone asked Brad what the constraints of Lua within Scribunto were. He said:


 * It depends on what the question means by "constraints". It certainly is a constraint that Lua can only get input as text strings passed to the and what can be fetched via frame:expandTemplate,  frame:preprocess, and the like. There's also the constraint that it can  only output wikitext not including pre-save transforms or transclusions  and other  constructs. It's  also a constraint that all Lua in the page is limited to 10 seconds CPU  time. And relative to standard Lua, Scribunto's Lua lacks all sorts of  functions (see mw:Extension:Scribunto/Lua reference manual).


 * Performance gains: Some templates are used to store data, and are invoked with #ifexist: in a main template. There are thousands of such "data"  templates.  With Lua, it's a lot more efficient to deal with a large  data structure in one module than a  in wikitext can handle.  The   function (probably coming to your wiki with MediaWiki  version 1.21wmf11; see the  deployment schedule) helps there too by only having to load  that data once per page no matter how many times the module is  #invoked.  Lua is pretty good about loading large blobs of static data,  and mw.loadData avoids the overhead of reparsing for each #invoke, so in  general things should be pretty good there.

Sharihareswara (WMF) (talk) 03:29, 13 March 2013 (UTC)

Tutorial not novice friendly
I'm the old syntax user to write Wiki templates without actual knowledge of other programming languages like C. But the tutorial in this page has skipped way too much detail. What is "local", "function" or "return"? No explanation. And where should I insert this local arg2 = frame.args[2] or "" into the previous codes? I tried myself many times but all I get is just script error. I know veterans hate babysitting, but this is not the way you attract people to help contribute the project. I would like to see a tutorial truly customized to Wiki users that shows a side-by-side comparison between a syntax template and lua module which use the same input and output the same result. Sorry if I'm being too rude in this message. -- Sameboat (talk) 05:08, 18 March 2013 (UTC)
 * This tutorial, at least in my view, is not a tutorial for Lua per se; rather, it is a tutorial for using Lua with MediaWiki. Again, the tutorial on the official Lua website is an excellent source of information. -happy5214 09:30, 18 March 2013 (UTC)
 * I am surprised that this is the only discussion I see about how lua can be used by a novice (sans C-like). I Was expecting a little better clue on how to implement even a simple variable function on a wiki page using lua. (Not the syntax of lua itself, but the structural syntax within Wiki.) Seems not working. Could someone elaborate the doc page a little bit more please? Viswaprabha (talk) 17:46, 29 April 2013 (UTC)
 * Oh I just saw this one! That is what I was looking for! So, it may be a good idea to keep a link here in the tutorial page too! Viswaprabha (talk) 18:41, 29 April 2013 (UTC)