“See also: Chapter 16 (OO) in _Programming in Lua_. The first edition is available online: Programming in Lua (first edition)”
Lua 语言设计者之一 Roberto Ierusalimschy 写的 Lua 教程,这里是官网免费放出的第一版。从基本语法讲到表、函数、闭包、协程、面向对象和完整示例,行文简练,类似 Lua 界的 K&R。因为是第一版,内容对应较早的 Lua 版本,新特性需对照手册和新版。
HN 上的人长期把它当作学 Lua 的标准入门书,称赞作者就是语言设计者、写得清楚简洁,尤其是协程、表和完整示例几章;也常建议配合官方参考手册读。有一条意见是 Lua 的面向对象文档分散。
想系统学习 Lua 的程序员
怎么读
由 Claude 根据这本书和 HN 上的说法整理,可能有错- 1从头读到表和函数相关章节,并在 Lua 解释器里实际运行
- 2协程与完整示例章节值得精读
- 3读时对照当前 Lua 版本的参考手册,留意与第一版的差异
- 4有 C 语言背景的读者可再看与 C 交互的部分
HN 书评
推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算“To get started with Lua, I'd recommend PIL: Programming in Lua (first edition)”
“Programming in Lua is an excellent example of what you're looking for.”
“Programming in Lua has a nice example of a maze game where state is passed around by emitting functions. It's a toy problem, but I think it's instructive”
“You can read about lua tables here: Programming in Lua (first edition)”
“The "Programming in Lua" book, by one of the authors of the language is far more friendly (an excellent book actually, the first version is available online for free: Programming in Lua (first edition)).”
看全部 20 条 →
“See Programming in Lua (first edition) for a bit more info.”
“Roberto Ierusalimschy's Programming in Lua[1] comes to mind.”
“The first edition of "Programming in Lua" is available for free online and might make for more interesting reading than the reference manual: Programming in Lua (first edition)”
“IMHO the gems in Chapter 10 (Complete Examples) and the clear explanation of coroutines are alone worth the price.”
“If you liked Kernighan and Ritchie's "The C Programming Language", then you'll love "Programming In Lua".”
“For those things, PiL ("Programming in Lua") is a much better resource.”
“There is a really nice example of the "goto" semantic for proper tail calls in "Programming in Lua".”
“"Programming in Lua" is Lua's K&R. It is a very well written technical book.”
“For serious depth, the two recommended by Gracana, PIL[4] and the reference manual[5], are fantastic.”
“Never mind Lua tutorials. Just read the manual, (链接), and maybe the canonical Programming in Lua book, Programming in Lua (first edition)”
“For Lua documentation, I recommend the Programming in Lua book, from Roberto Ierusalimschy (lead Lua dev).”
“The official book is a great start: Programming in Lua (first edition)”
“The Lua documentation is sparse but pretty complete and the PIL book is considered the standard. See what you think... [0]”
“Why is the basic documentation [1] on whether/how to implement OO Lua so contradictory and all over the place?”