HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
kikito
middleclass
Lua2013–2023
kikito / middleclass

middleclass

Object-orientation for Lua

6Distinct people
7Mentions
1Explicit recommenders
1.9KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Object-orientation for Lua

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

Just going to link one of my favorite libraries for LÖVE. https://github.com/kikito/middleclass

grimgrin used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year7 dated mentions

Observed mentions: 2013-01-27 21:11:44 UTC to 2023-05-28 20:53:22 UTC.

012013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20132014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC101
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC101
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC101
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC000
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

7 sources
The ConTeXt typesetting system tightly integrates Lua. One aspect of Lua I dislike is that it isn't object-oriented. What's impressive is that the language can be extended to be so in astonishingly little code: * https://github.com/kikito/middleclass/blob/master/middleclas... Using OOP, typesetting a hexagonal grid and a symbolic representation of a neural network on top is easier develop, IMO. A vertex defines a point in 2D space: * https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos... An edge connects two vertices: * https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos... A graph connects edges: * https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos... A priority queue serves for ordering edges by weight of adjoining vertices: * https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos... With these concepts
Read the rest
in hand, we can typeset a grid and a "neural network" on top: * https://github.com/DaveJarvis/keenwrite-themes/blob/main/bos... Here's an example of the output from the first chapter: * https://i.ibb.co/19DCDZy/ch-1.png And a later chapter, where the "network" has grown in complexity: * https://i.ibb.co/ncf16vg/ch-2.png This is for my near future hard sci-fi book on AGI. I'm looking for alpha readers to give me feedback. See profile for contact details. P.S. There's a subtle bug in the code that can result in one or two disconnected vertices. If you spot it, let me know!
In Lua: The Little Language That Could
My libraries were originally made in Lua in order for me to better work with and learn the LÖVE framework. * inspect.lua [1] is the most popular one. It transforms any Lua value (including deeply nested tables) into human-readable strings. It is very useful for debugging all kinds of Lua projects, not just games. It is a partial reason why I got my current web dev job at Kong. * middleclass [2] is somewhat popular amongst people coming into Lua from OOP languages. I don't use it myself anymore and consider it a bit of a "clutch". Still, it has helped a lot of people. * bump.lua [3] is a box-based collision detection and resolution library. The later part has some known bugs I never figured out. Still has been used by some people to do some fun stuff. * gamera.lua [4] is a minimalist camera-system for LÖVE. * anim8 [5] is an animation libr
Read the rest
ary for LÖVE There's many other projects on my github profile. I must warn you that they are all in several degrees of disrepair, I pretty much abandoned all of my open source efforts when my first child was born. Ran out of free time and energy. These days, when I want to scratch my game-making itch, I fire up PICO-8, an even more minimalistic gamedev environment than LÖVE. I find the limitations it imposes refreshing. It also means that I cannot use most of my old libraries. Which is fine. [1] https://github.com/kikito/inspect.lua [2] https://github.com/kikito/middleclass [3] https://github.com/kikito/bump.lua [4] https://github.com/kikito/gamera.lua [5] https://github.com/kikito/anim8
In Doing what you love when the money won’t follow
The "bare-bones" nature of Lua is really nice when you need it, so I like that it's an option. But I would guess that most of the time you need Penlight [1], and I found middleclass [2] to be a pretty good OO library. After that, just build some abstractions. It's very easy to build DSLs in Lua, or if that's a little too dynamic for you (it is for me), it's very easy to use patterns like Builder or use an OO library and build some class taxonomies. Anyway, Lua's not batteries included in lots of ways. It does take a little time to build it up for your specific usage. But most users think that's a core feature. [1]: https://stevedonovan.github.io/Penlight/api/index.html [2]: https://github.com/kikito/middleclass
In MoonScript: Dynamic scripting language that compiles into Lua
> 1-based indexing is just a silly departure from decades of ingrained thinking This on only true for (not too old) programmers. - Older programmers, taught pre-C, may remember that most languages were typically 1-based (Fortran, Pascal, Algol, Smalltalk...). - Scientists usually use 1-based notation. I have avoided countless off-by-one by implementing papers in Lua. Matlab is also 1-based, probably because it is a language for mathematicians and scientists. - In general, non-programmer tend to count from 1 and not 0. > the only inheritance is prototype-based "classes" that are implemented via gross metatable hacking If you need to you can implement non-prototypal object models, with metatables or with closures if you don't like them. My recommended object library is https://github.com/kikito/middleclass for people who want to write ojbec
Read the rest
t-oriented code (I usually don't). > dictionaries masquerade as lists but can unintentionally become dictionaries if you mistakenly put a non-numeric key in them I agree with this one, mostly. I would appreciate a purely sequential data structure ("list").
In My love-hate relationship with LuaJIT (2015)
Hi, I am the author of the library mentioned in the article (not the article author, that's someone else). You seem to have missed the link to the OOP library used, so here it is: https://github.com/kikito/middleclass Also, notice that in other comments on this thread I mention that I don't think OOP in Lua it's a one-size-fits-all thing. I think middleclass has its uses, but most of the time plain Lua with some metatables does the trick just fine.
In The Power of Lua and Mixins

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.