kikito/middleclass
kikito/middleclass has 1,924 GitHub stars and 195 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 00:18 UTC. Last push 2025-11-03.
Object-orientation for Lua
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalmiddleclass
A simple OOP library for Lua. It has inheritance, metamethods (operators), class variables and weak mixin support.
Quick Look
local class = require 'middleclass'
local Fruit = class('Fruit') -- 'Fruit' is the class' name
function Fruit:initialize(sweetness)
self.sweetness = sweetness
end
Fruit.static.sweetness_threshold = 5 -- class variable (also admits methods)
function Fruit:isSweet()
return self.sweetness > Fruit.sweetness_threshold
end
local Lemon = class('Lemon', Fruit) -- subclassing
function Lemon:initialize()
Fruit.initialize(self, 1) -- invoking the superclass' initializer
end
local lemon = Lemon:new()
print(lemon:isSweet()) -- false
Documentation
See the github wiki page for examples & documentation.
You can read the CHANGELOG.md file to see what has changed on each version of this library.
If you need help updating to a new middleclass version, read UPDATING.md.
Installation
Just copy the middleclass.lua file wherever you want it (for example on a lib/ folder). Then write this in any Lua file where you want to use it:
local class = require 'middleclass'
Specs
This project uses busted for its specs. If you want to run the specs, you will have to install it first. Then just execute the following:
cd /folder/where/the/spec/folder/is
busted
Performance tests
Middleclass also comes with a small performance test suite. Just run the following command:
lua performance/run.lua
License
Middleclass is distributed under the MIT license.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,804 starspublic-apis/public-apis
A collective list of free APIs
497,037 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
441,207 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,149 stars