4 ms·
Objective Lua
- ardit33 17y agoReally? Seriously, Lua is a fine language, and doesn't need this objective-crap thrown in top of it. How to make a simple thing, more complicated. Just b/c you can, doesn't mean you should.
- mbrubeck 17y agoMy friend Josh is working on a big project in Lua, and part of his wishlist is a Lua-compatible language with "classical" OO (language-level classes and interfaces): http://blog.reverberate.org/2009/02/09/disappointment/ http://blog.reverberate.org/2009/02/09/disappointment/ http://blog.reverberate.org/2009/02/09/static-lua/ http://blog.reverberate.org/2009/02/09/static-lua/
- silentbicycle 17y agoI don't see the point of adding classes* to Lua, but implementing points 1 and 7 (the error for undeclared vars and nonexistent fields, not the "as userdata" part) is done as an example in PiL. See strict.lua. Any variables not declared as local default to globals, and you can trap the use of globals quite easily by hooking __index and __newindex in the global table's metatable. * With a class-based system, you first write an abstract version of what you need, then create instances. With prototypes, you just create the instance, and if generalizing is worth doing (it often isn't!), you can spawn new objects based off of it. I wonder if classes themselves encourage over-abstraction. Of course, you have to use prototypes idiomatically, or they just seem like weird classes. (This is also orthogonal to static analysis.) To really take advantage of static typing, you would probably need to add support for it to the Lua VM. I don't know of any languages as lightweight as Lua with good static type systems, though - and I agree that an ML-like language as lightweight and clean as Lua could be really nice.
- stcredzero 17y agoTo really take advantage of static typing, you would probably need to add support for it to the Lua VM Understandable, but not entirely correct. See StrongTalk. You can have the static typing be in the parser/compiler frontend only. The programmer can get feedback about type metadata, and can use it in refactoring and ensuring program correctness. The VM has to know bupkus about that stuff. In particular Lua's VM is good enough that in most cases it's not needed for performance reasons. This makes the typing system somewhat circumventable. But the type system is usually circumventable even in a traditional static typed language. At some point, you have to count on programmers not doing stupid things. On the other side of the coin, such type systems are optional. Which means that you can have less typing for prototyping and rapid development, and more for mature code going into production and maintenance.
- silentbicycle 17y agoI originally had a few lines about how it would "just" be usable for static analysis, debugging, etc. otherwise, but that would still be worthwhile. I haven't looked into StrongTalk yet though, so thanks. :)
- stcredzero 17y agoWhoops, it's spelled Strongtalk. Arrgh!
- startingup 17y agoI agree. This would only complicate the language, without adding much of value.
- jpatte 17y agoThe main advantage in bringing OO concepts in the Lua world is actually to improve code modularization. There is no such thing as classes or modules in Lua - although there is a notion of 'environments' defining the scope of global variables. Grouping related functions/variables into classes is just a way to improve the maintability of large Lua chunks, it's not about transforming the language into something less simple. I wrote my own library to implement OO concepts in pure Lua 5.1 several years ago; the code and details are still available at http://lua-users.org/wiki/YetAnotherClassImplementation http://lua-users.org/wiki/YetAnotherClassImplementation.
- joeyo 17y agoI suspect you know this, but as of Lua 5.1 there are modules: http://www.lua.org/manual/5.1/manual.html#5.3 http://www.lua.org/manual/5.1/manual.html#5.3
- silentbicycle 17y ago> There is no such thing as classes or modules in Lua Actually, there is a module system (http://www.lua.org/manual/5.1/manual.html#5.3 http://www.lua.org/manual/5.1/manual.html#5.3), built on the environment manipulation methods. It was added to the language with 5.1, and seems a bit less mature than the rest of the language, but it's there. It's similar to Erlang's module system, except instead of listing exports at the top, anything not flagged as local is exported.
- jpatte 17y agoWhoops, my bad. You're right, I forgot about the module system of Lua 5.1. Guess I will have to refresh some clusters of memory around here :o)
- silentbicycle 17y agoWell, the nice part with Lua is there's only so much you can forget. :)
- dchest 17y agoThat's one of the best descriptions of a programmer's tool I've ever seen.
- acg 17y ago... said the project manager
- callmeed 17y agoA bit unrelated, but how do I find a Lua developer? I have a Lua project I need done soon.
- bayareaguy 17y agoPost on the lua mailing list: http://www.lua.org/lua-l.html http://www.lua.org/lua-l.html
- bayareaguy 17y agoAn interesting project but I don't really see any practical need for this as Lua provides plenty of ways to construct just about any object system.