Hello Mike,
Thanks for letting us know about moonscript. We feel that object oriented programming is a great thing for desktop applications but for mobile apps there is just simply too much overhead added. Check out the benchmark test here :
http://lua-users.org/wiki/ObjectBenchmarkTests
In effect what it says is that directly accessing a table is twice as fast as using the object oriented approach. If performance is a concern for you then please do not use OOP in lua.
Our solution for this would be to give you the best of both worlds, the readability of OOP and the performance of non OOP. The upcoming Glider 1.7 IDE will allow you to define your own virtual classes and even extend virtual classes. The difference is that all this information will be contained in comments and no runtime overhead is added (still direct table access). Here is a typical OOP scenario we purpose:
---
-- @param x @class number
-- @param y @class number
-- @param rotation @class number
-- @return @class entity
--
function createEntity(x,y,rotation)
---@classdef entity
local entity = {}
entity.x = x;
entity.y = y;
entity.rotation = rotation;
return entity;
end
--- Ship inherits Entity
-- @param entity @class entity
-- @param isEnemy @class boolean
-- @param weapon @class weapon
-- @return @class ship
--
function createShip(entity, isEnemy, weapon)
---@classdef ship @extends entity
local newShip = entity;
newShip.isEnemy = isEnemy;
newShip.weapon = weapon;
function newShip:fire()
self.weapon:fire();
end
return newShip;
end
The IDE will give you a warning if you try to do something like:
createShip(1,2,3)
And the autocomplete knows whats inside each of the objects so you and your team do not have to keep referring to an object reference.
So type safety is maintained, but at the IDE level not at the device level.
Regards,
M.Y. Developers
[import]uid: 55057 topic_id: 29444 reply_id: 118249[/import]