A 30-lines library for object-orientation in Lua


Join the chat at https://gitter.im/Yonaba/30log

Build Status Coverage Status Lua License

30log, in extenso 30 Lines Of Goodness is a minified framework for object-orientation in Lua. It provides named and unnamed classes, single inheritance, metamethods and a basic support for mixins.
In 30 lines. No less, no more.
30log was written with Lua 5.1 in mind, but is compatible with Lua 5.2, Lua 5.3 and LuaJIT.



Current release is 1.0.0. See other releases.


This will clone the repository, as-is, and deliver the cutting edge release. Might be unstable.

git clone git://github.com/Yonaba/30log.git


This will download and install the latest stable release from Luarocks servers.

luarocks install 30log


Find the project page at yonaba.github.io/30log.
A full documentation is available on the wiki.

Class-Commons support

Class-Commons is an interface that provides a common API for a wide range of object orientation libraries in Lua. There is a small plugin, originally written by TsT which provides compatibility between 30log and Class-commons.
See here: 30logclasscommons.


You can run the included specs with Telescope using the following command from Lua from the root foolder:

lua tsc -f specs/*

About the source


30log was initially designed for minimalistic purposes. But then commit after commit, I came up with a source code that was obviously surpassing 30 lines. As I wanted to stick to the "30-lines" rule that defines the name of this library, I had to use an ugly syntax which not much elegant, yet 100 % functional.
For those who might be interested though, the file 30logclean.lua contains the full source code, properly formatted and well indented for your perusal.


The file 30logglobal.lua features the exact same source as the original 30log.lua, excepts that it sets a global named class. This is convenient for Lua-based frameworks such as Codea.



This work is MIT-Licensed.