Lua Source Code Reading Plan

2017-12-15 03:36Edit this page

Lua source code series:

Using Lua in OpenResty projects is both enjoyable and frustrating. Lua’s minimalist design allowed me to build a CDN control system in just a few days two years ago, but problems emerged as the business system gradually took shape. Now I have two solutions before me:

  1. Use a state machine - implement the core part of the framework with a state machine, changing the previous control flow into individual states
  2. Use sandboxing - abstract new phases. Use preset sandbox environments to do specified things in each phase.

If using a state machine, it might greatly complicate the core part of the system, making it unmaintainable later. For sandboxing, the problem is that I only half-understand Lua’s underlying implementation. After seeing Yun Feng’s blog, I decided to take time to read through Lua’s source code to deepen my understanding of Lua. During the reading, I also hope to come up with an ideal Lua architecture for OpenResty projects.

Here’s Yun Feng’s Lua Source Code Appreciation

I’ll update here with some thoughts and knowledge gained after reading the Lua source code.

This is my project on GitHub with Chinese comments added to the lua-5.2.2 source code: https://github.com/xiaocang/lua-5.2.2_with_comments

Unless otherwise stated, articles on this blog are licensed under the Creative Commons Attribution 4.0 International License. Please credit the original author and source when sharing.


Tags: lua

Leave a comment

Creative Commons © 2013 — 2026 xiaocang | Theme based on fzheng.me & NexT | Hosted by Netlify