3 ms·
The actual statement Larry Wall gave wasn't that bad... I thought Perl 5 had an oversimplified object system till I saw Lua. In Lua, an object is just a hash,
by draegtun 14y ago
The actual statement Larry Wall gave wasn't that bad...
I thought Perl 5 had an oversimplified object system till I saw Lua. In Lua, an object is just a hash, and there's a bit of syntactic sugar to call a hash element if it happens to contain code. Thats all there is. They don't even have classes. Anything resembling inheritance has to be handled by explicit delegation. That's a choice the designers of Lua made to keep the language very small and embeddable. For them, maybe it's the right choice.
ref: http://www.perl.com/pub/2007/12/06/soto-11.html http://www.perl.com/pub/2007/12/06/soto-11.html
Also IIRC Wall's original Lisp quote starts with him praising Lisp and then ending with this infamous|humorous quip.
- flyinRyan 14y agoThis description sounds to me almost exactly like what Perl does with it's OO (Perl's reall OO. Moose and all that are libraries built on top of Perl).
- rjbond3rd 14y agoBut even Perl's barebones (non-Moose) OO has inheritance. Once you add in Moose, you now have an API to your OO which is unusual. Personally, I think Lua is amazing. Rolling your own OO system in the language itself is pretty awesome, if you like that sort of thing. Everything has to be implemented in -something-, right?
- draegtun 14y agoIt's very similar in that they both expose the OO inner workings but after that they're quite different. Perl requires a blessed reference (which doesn't have to be a hash but often it is the best option!) which only contains the objects state. So unlike a Lua object hash the behaviour is maintained by Perl in dynamically scoped packages/subroutines (classes/methods).