编程与软件工程tylerneylon.com
15 分钟学会 Lua
Learn Lua in 15 Minutes
2013 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是一篇以可运行代码片段为主的 Lua 快速入门教程,作者 Tyler Neylon 声称 15 分钟即可掌握 Lua 的基本语法和常用特性。它以单页、示例驱动的形式覆盖变量、函数、表、控制流等核心内容,后来也催生了 learnxinyminutes.com 这类教程风格。
为什么经久不衰:它开创了'用一页自解释代码片段学一门语言'的极简教程风格,七年后仍被反复推荐,是快速上手 Lua 或了解这种教学方式的最佳样本。
HN 评论精选
示例驱动的单页教程胜过传统文档
太棒了。比起分散在层层目录下的长篇大论文档,我任何时候都更愿意要一份覆盖 95% 使用场景、带少量注释的自解释示例代码大列表。
karpathy查看英文原文
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.
教程只是入门,Lua 的协程和 C 互操作才是真正的杀手锏
这是个不错的入门,但 Lua 还有更深的东西。比如它有很好的协程实现,熟悉 Scheme 续延的话会发现用途几乎相同(类似 Python 生成器或 Ruby fiber,但边界情况更少)。C 互操作也是大事——Lua 看似一个更干净的 JavaScript,但如果你同时精通 C,它会实用得多;而且只要有 ANSI C 编译器和一点空间,Lua 就能跑。
silentbicycle查看英文原文
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 you're also proficient in C. Also, Lua will run anywhere you have an ANSI C compiler and a modest amount of space.
指出教程中局部函数两种写法等价的说法有误
我要来当'那个较真的人':教程里 local function g(x)... 与 local g = function(x)... '等价'的说法不对。按 Lua 参考手册,正确的等价写法是先声明 local g 再赋值,区别只在函数体引用自身时才体现。
sharkbot查看英文原文
I'm going to be "that guy": -- These are the same: -- ...snip... local function g(x) return math.sin(x) end local g = function (x) return math.sin(x) end According to the Lua Reference Manual [1], this example isn't correct. Rather, this is the correct translation: local function g(x) return math.sin(x) end local g; g = function (x) return math.sin(x) end From the manual: "This only makes a difference when the body of the function contains references to f." [1] http://www.lua.org/manual/5.2/manual.html#3.4.10
Lua 在游戏脚本和 NGINX 高性能场景中极为实用
Lua 是门怪异的小语言,但在它设计的目标领域——嵌入式脚本——绝对完美。我做游戏开发时用它运行时测试各种交互和移动,省下数千工时;现在我在 NGINX 里用它处理高速请求。Lua、LuaJIT 和 Redis 让我职业生涯赚了很多钱。
VWWHFSfQ查看英文原文
Lua is a funky little language and runtime but it is absolutely perfect for scripting in the domain that it was designed for: embedded. I used to do a lot of game dev and it was incredible for testing different interactions/movements etc at runtime just to get all the inputs right and then implement in the game code. It has saved me probably 1,000s of man-hours in my career. Nowadays I use it in NGINX for high-velocity requests that are just backed by Redis. Lua, LuaJIT, and Redis have made me a lot of money in my career. I'm forever indebted to their incredible creators and community.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选