Day 2: Tables All the Way Down

Today, we’re going to look at two concepts that define the Lua experience: tables and coroutines. As with many prototype languages, tables define your data. Coroutines define your control flow. Both are simple but tremendously powerful, underpinning everything from Lua’s object system to your own domain-specific languages.

Let’s begin with tables.

One of the first things new programming language tutorials do is inundate you with a laundry list of data structures: arrays, tuples, vectors, lists, dictionaries, and so on. Each of these has its own API, syntax, quirks, and performance characteristics.

These collections are all useful, but when I’m first trying out a language, I’m usually wondering about much more basic ...

Get Seven More Languages in Seven Weeks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.