Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Threading I'll grant you, but prototype-based OO is practically Lua's defining feature. Could you expand?


Well, I guess that's not really fair. Obviously you can implement prototype-style OO, more or less, using the metatable and metamethod facilities. But as an old NewtonScript developer, I rather find

    foo = { x = 1, y = 2 }
    mt = { __index = bar }
    setmetatable(foo, mt)
to be crazy compared to

    foo := { _proto: bar, x: 1, y: 2 }
The uncleanliness of function declarations in Lua compared to NewtonScript also gets to me in this way. At any rate, to me, the metatable facility feels like a hack. That's not to denigrate it: it's a very flexible and clever gizmo which can be used for a variety of cool things. But to me proto-style OO languages are notable for their elegance and simplicity, and metatables expose a fair bit of wiring and boilerplate. [It also wasn't a good sign that the whole OO section in "Programming in Lua" was about "classes" :-( ]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: