Live data from Hacker News

Learn Lua in 15 Minutes

tylerneylon.com

61–70 of 99 posts

Re: Learn Lua in 15 Minutes

#61
post #6

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.

It's an interesting method, reminded me of vimtutor.

Re: Learn Lua in 15 Minutes

#62
Great sheet.

  -- Variables are global by default.
  thisIsGlobal = 5  -- Camel case is common.
-- Undefined variables return nil. -- This is not an error: foo = anUnknownVariable -- Now foo = nil.

-- Only nil and false are falsy; 0 and '' are true!

Didn't read further. Bad language design. Must die.

Re: Learn Lua in 15 Minutes

#65
post #56

Anyone else catch the Gauss reference[1] in the for loop section? [1] http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss#Anecdotes

You have a keen eye for subtle references! I didn't expect many people to get that one :) There's another math anecdote reference hidden in there as well - probably even more obscure than Karl's sum.

Re: Learn Lua in 15 Minutes

#67
post #56

Anyone else catch the Gauss reference[1] in the for loop section? [1] http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss#Anecdotes

You have a keen eye for subtle references! I didn't expect many people to get that one :) There's another math anecdote reference hidden in there as well - probably even more obscure than Karl's sum.

Upon reading this comment had to skim the whole thing looking for more (hadn't yet finished reading). No more maths references than tau found yet. :/

Re: Learn Lua in 15 Minutes

#68
post #62

Great sheet. -- Variables are global by default. thisIsGlobal = 5 -- Camel case is common. -- Undefined variables return nil. -- This is not an error: foo = anUnknownVariable -- Now foo = nil. -- Only nil and false are falsy; 0 and '' are true! Didn't read further. Bad language design. Must die.

First two can be changed quite easily: http://metalua.luaforge.net/src/lib/strict.lua.html

The last one is awesome.

Re: Learn Lua in 15 Minutes

#69

A logical next step might be to do do the Lua Missions (read: koans): https://github.com/kikito/lua_missions . (Disclaimer: The missions look good, but I haven't personally tried them.)

Actually, the Lua Missions are excellent! I highly recommend taking the time to work through them. More than just a series of exercises (like most of the foo-koans), there's actually a narrative and a larger lesson you can learn if you work through the full problem set.

Re: Learn Lua in 15 Minutes

#70

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.) 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…

Coroutines are tricky, and you need to explain them, not just present a bit of code. I think it is the right decision to omit them from a 15-minute intro. The C API is way out of scope.

I would cover assert() statements and the common (exit_status, result) var return, since that is so idiomatic. Maybe also loading chunks.

Post reply on HN