Preface
This book covers integration between the Lua and C languages with emphasis on building a user-facing API. Your API might be used to speed up development within your company; it might be released to customers as a way to customize your app or game; and it could be used as the foundation of a domain-specific language within a platform you’re developing.
I’m going to assume that you know Lua. But if you don’t, you’re in luck: it’s easy to pick up. If you happen to know JavaScript, a great place to learn Lua is my short article series Learn Lua from JavaScript (O’Reilly). Even if the language is new to you, Lua is so readable that you could probably read this entire book without having to look at a reference. My focus will be on the fundamentals of creating an API written in a combination of C and Lua, and exposed to users as a pure-Lua interface.
Note
Although in some contexts the term API implies web-based interaction, such as a RESTful HTTP-based interface, this book is not about this type of API; rather, it’s about creating a set of Lua classes and functions used to programmatically work with a local application.
This book is split into two parts: Part I, Making a Lua API, describes how C and Lua can interface with each other, whereas Part II, Script Safety, explains how to safely run scripts written by users who might make mistakes or might even purposefully attempt to break your system. Not very nice! But this book will help to prepare you for issues like this.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access