This is awesome. I will take [a single huge list of self-explanatory example snippets (with a few short comments here and there) for 95% of use cases] over [detailed walls-of-text docs pages spread across a hierarchy of topics] any day.
Along the same lines is <a href="http://hyperpolyglot.org/" rel="nofollow">http://hyperpolyglot.org/</a> (which has been posted here a few times). This is useful both for learning a new language and for a quick reference for languages you're not so hot on. It's also very interesting to compare similarities and how languages have influenced each other.<p>It seems (from the comments here and my own experience) that many people really like this style of learning. It would be great to see it applied in more areas.
This is a good start, but there's also some deeper ideas in Lua. It has a good implementation of coroutines, for example; if you're familiar with continuations from Scheme, they fit most of the same uses. (They're like generators from Python or fibers from Ruby, but with less edge cases.)<p>The C interop is also a Big Deal. Lua seems like a cute little language, like a cleaner Javascript, but it's a LOT more useful if you're also proficient in C. Also, Lua will run anywhere you have an ANSI C compiler and a modest amount of space.
I'm going to be "that guy":<p><pre><code> -- These are the same:
-- ...snip...
local function g(x) return math.sin(x) end
local g = function (x) return math.sin(x) end
</code></pre>
According to the Lua Reference Manual [1], this example isn't correct. Rather, this is the correct translation:<p><pre><code> local function g(x) return math.sin(x) end
local g; g = function (x) return math.sin(x) end
</code></pre>
From the manual: "This only makes a difference when the body of the function contains references to f."<p>[1] <a href="http://www.lua.org/manual/5.2/manual.html#3.4.10" rel="nofollow">http://www.lua.org/manual/5.2/manual.html#3.4.10</a>
This is awesome.<p>On that note, I don't understand all the javascript craze. Lua has been around for quite some time, and it's small, with well-defined semantics, a nice set of features, the interpreter is small and very fast, you can get even faster with LuaJIT, etc. Browsers should have adopted that ages ago.
A logical next step might be to do do the Lua Missions (read: koans): <a href="https://github.com/kikito/lua_missions" rel="nofollow">https://github.com/kikito/lua_missions</a>.<p>(Disclaimer: The missions look good, but I haven't personally tried them.)
Lua can be great. I've worked with it extensively on a personal project, where I've embedded it in a C++ app. However, there are some things that you will hate:<p><pre><code> * Trying to correctly do "inheritance"
* Having to write all of your batteries for common ops
* Array indices begin at 1!
* Poor debugging support
</code></pre>
Aside from those thing, Lua is great. It's crazy fast and easy to embed.
I prefer learning this way also, so I wrote something sort of similar for Vimscript a while back. The # of people that ever need to use vimscript is low, but it's out there for people to get their feet wet.<p><a href="http://andrewscala.com/vimscript/" rel="nofollow">http://andrewscala.com/vimscript/</a>
I would like to say that the easiest way for me to learn lua really fast was to build games with Corona using lua.<p>Having a great tool that gives great feedback right away makes learning a language more fun IMO.
Nice work!<p>One nitpick: local function declarations, like<p><pre><code> local function g(x) return g(x) end
</code></pre>
are actually the same as writing<p><pre><code> local g;
g = function (x) return g(x) end
</code></pre>
. Without that first local g; statement, local functions wouldn't be able to call themselves recursively.
This is great! I wish every language had an intro like that :)<p>It was interesting to find resemblance of Lua's classes to Perl's blessing. Always meant to look into the language and this tutorial made me do it.<p>I also learned about the LÖVE game engine, which I'm going to play with this week. Thank you!<p><a href="http://love2d.org/" rel="nofollow">http://love2d.org/</a>
First, that was very useful; bookmarked.<p>That took me 30 minutes to read. I think I might feel like I've learned the language after spending 8 hours working the examples a la "Learn Python the Hard Way". Luckily, I'm not competing with the folks here that learned it within 15 minutes ;-).
This is a neat little reference but I can't waste the opportunity.<p>I've seen people say they've never seen complaints about fonts being too big? Well here I am, complaining that the fonts are so big this page is hard for me to read without zooming out.
That was a pretty cool crash course on Lua Tyler! Thanks for putting that together and sharing it. After having had worked with numerous languages over the years such as Fortran, Pascal, Ada, C, Java, C++, C#, Python and Objective-C, I must say that working with Lua is my favorite. I'm thankful to a buddy of mine for introducing it to me. My own personal experience has shown me that working with Lua really allows you to focus on solving the problem versus getting wrapped around the axle at the programming language level. Thanks again
I learned to love lua when writing basic sysadmin scripts for OpenWRT based systems. I had previously used perl for sysadmin stuff, but perl (even microperl) took too much space on OpenWRT boxes with 4MB flash drives. Lua to the rescue. Now I chafe when I have to go pack to perl.<p>I do wish someone had handed me this on the first day I realized I needed lua.
Maybe for the next Ludnum Dare...<p>nice write up comparison of lua based game engines: <a href="http://www.gamefromscratch.com/post/2012/09/21/Battle-of-the-Lua-Game-Engines-Corona-vs-Gideros-vs-Love-vs-Moai.aspx" rel="nofollow">http://www.gamefromscratch.com/post/2012/09/21/Battle-of-the...</a>
Anyone else catch the Gauss reference[1] in the for loop section?<p>[1] <a href="http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss#Anecdotes" rel="nofollow">http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss#Anecdotes</a>
This is very cool, the only way I can see this could be improved upon is by adding unit tests somehow (so that you can catch behavior changes when upgrading to a newer version of lua).
Having a font size of 25.33pt makes the website impossible to read without zooming out 3 steps. I would be happy if people stopped using tiny and huge default font sizes.
Great sheet.<p><pre><code> -- Variables are global by default.
thisIsGlobal = 5 -- Camel case is common.
</code></pre>
-- Undefined variables return nil.
-- This is not an error:
foo = anUnknownVariable -- Now foo = nil.<p>-- Only nil and false are falsy; 0 and '' are true!<p>Didn't read further. Bad language design. Must die.
Obligatory:
Teach Yourself Programming in Ten Years — <a href="http://norvig.com/21-days.html" rel="nofollow">http://norvig.com/21-days.html</a>