
Objective Lua - fogus
http://www.cowlark.com/objective-lua/
======
ardit33
Really?

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
My 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/static-lua/>

~~~
silentbicycle
I 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
_To 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
I 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
Whoops, it's spelled Strongtalk. Arrgh!

------
jpatte
The 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>.

~~~
jpatte
Whoops, 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
Well, the nice part with Lua is there's only so much you can forget. :)

------
bayareaguy
An 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.

------
callmeed
A bit unrelated, but how do I find a Lua developer? I have a Lua project I
need done soon.

~~~
bayareaguy
Post on the lua mailing list: <http://www.lua.org/lua-l.html>

------
dchest
That's one of the best descriptions of a programmer's tool I've ever seen.

~~~
acg
... said the project manager

