Hello,
For my project i use an OOP library : GitHub - rxi/classic: Tiny class module for Lua.
I realized that there is others libraries like : GitHub - kikito/middleclass : A simple OOP library for Lua.
As i'm looking for a fast and easy to use OOP library, do you think my choice is right ? or, may be i should switch to kikito's library or to another one ?
Have you some library to suggest ?
thanks in advance
Looking for fast and simple OOP library
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Looking for fast and simple OOP library
I generaly use Middleclass, but you should use whatever you feel better with. If you like Classic then just go with it.
I think currently the only one that takes performance as the first objective is Classy which is similar to Middleclass. And the one that takes filesize into consideration is 30log, Classic is also really tiny!
Middleclass is the most complete one, with inheritance, full metamethods support and subclassing. Also I consider it's documentation to be great!
Again, use whatever you think works best, you should try them and decide on yourself. They are all very similar though!
I think currently the only one that takes performance as the first objective is Classy which is similar to Middleclass. And the one that takes filesize into consideration is 30log, Classic is also really tiny!
Middleclass is the most complete one, with inheritance, full metamethods support and subclassing. Also I consider it's documentation to be great!
Again, use whatever you think works best, you should try them and decide on yourself. They are all very similar though!
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Looking for fast and simple OOP library
Thanks Positive07, to share your experience about OOP library.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: Looking for fast and simple OOP library
I think the forum was trying to answer this question, and I agree.
Re: Looking for fast and simple OOP library
Is it fast and easy to use? Does it have the features you need, but not too many features you don't need? If so, it's probably fine.As i'm looking for a fast and easy to use OOP library, do you think my choice is right?
If you only use single inheritance, and don't need mixins or other fancy stuff, it should be either fairly trivial or somewhat educational to whip something up yourself; for example if you just want the convenience of being able to define methods with the Class:method syntax. Here's the "class.lua" from a project I worked on recently where I decided to use classes to achieve OOP.
Code: Select all
return function (super)
local meta = { __index = {} }
return setmetatable(meta.__index, {
__call = function (_, ...)
local instance = setmetatable({}, meta)
if instance.init then
instance:init(...)
end
return instance
end,
__index = super
})
end
Code: Select all
local bark = function (self) print(self.name .. ' says woof') end
local Dog = function (name) return { name = name, bark = bark } end
local dog = Dog('Rufus')
dog:bark() -- 'Rufus says woof'
Who is online
Users browsing this forum: Google [Bot] and 5 guests