Page 2 of 3

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 9:01 am
by bartbes
Projects I've done without classes (of reasonable size) would quickly become a mess, sure, I agree, don't go learn classes before you grasp the language, but be sure to give it a look once you do. (Not saying you should use classes then either, but if it fits your workflow, please do, the freedoms of lua!)

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 9:11 am
by BlackBulletIV
Totally agree with what kikito said. It took me a while to grasp OOP, but I didn't put it off as long as I could; since I got it, I couldn't code without it. Unless the problem domain is tiny, neglecting to think about architecture, is best illustrated by a bridge builder who needs to make a crossing across a large river, but doesn't want to think about the architecture.

If thought isn't taken to architecture, everything is a mess. In the analogy of the builder, this situation would be the same as all his materials lying all over the place.

Shifting from procedural to OOP, doesn't make your stop thinking about problems and solutions. You still think about those same problems, but have good architecture to help you implement a clean solution. Of course, for simple stuff (tiny problems), I still use procedural, it's most certainly the best way to go in that case. But when things get bigger, OOP is like pain relief for a massive headache.

Anyway, I should probably stop now; I'm an OOP nut, so I like to defend it. :)

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 1:54 pm
by Lafolie
Hate to quote myself but I feel that you quoted me out of context.
Lafolie wrote:...the only problems I can foresee with using Löve are OOP and network-functionality. Both of these issues, however, are pretty much negated...

... though I would recommend learning the fundamentals of object-orientation as early as possible...
As early as possible. Which means that you should get a grasp of the fundamentals first, of course. I like to balance out my arguments.

And of course I agree with all the statements about OOP being difficult and taking time to grasp. It is an incredibly abstract concept after all. I hope this is all helpful to the original poster by the way :)

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 9:58 pm
by Spade
Concerning OOP then, how difficult is it to get some sort of class system going?

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 10:42 pm
by Lafolie
As simple as

Code: Select all

require("3rdparty_script")
There's one on the wiki, with varying degrees of complexity, each with their own examples and explanations. If you're absolutely new to scripting then I'd suggest you get a hang of the basics first :)

Re: Considering picking up Lua

Posted: Thu Apr 07, 2011 10:42 pm
by BlackBulletIV
Spade wrote:Concerning OOP then, how difficult is it to get some sort of class system going?
By the do you mean, how difficult is it to create an OOP system in Lua or how difficult is OOP to learn?

If the former, then it doesn't take a lot of code at all (anywhere from 20 to 150 or so lines is pretty good). However it does take a solid knowledge of Lua, especially a good grasp on tables, metatables, and functions (and most likely closures).

If the latter, it really depends on the person. It usually does take a little while to get, that's my experience anyway.

EDIT: Oh yeah, you could of course use a third-party OOP system. I highly suggest MiddleClass.

Re: Considering picking up Lua

Posted: Fri Apr 08, 2011 12:16 am
by Robin
BlackBulletIV wrote:EDIT: Oh yeah, you could of course use a third-party OOP system. I highly suggest MiddleClass.
MiddleClass is rather complex. Especially if you're new to all this, SECS might be easier to use.

Re: Considering picking up Lua

Posted: Fri Apr 08, 2011 12:20 am
by BlackBulletIV
Complex? I find it really simple (unless you're talking about hacking around with internals, like swapping metatables and stuff), certainly more simple than other language's OOP system. All you've gotta remember is

Code: Select all

NameForClass = class('NameForClass', OptionalSuperClass)

function NameForClass:initialize(...)
  -- initialize here
end

-- other functions created the same way

instance = NameForClass:new() -- or NameForClass()
That's simple isn't it?

Re: Considering picking up Lua

Posted: Fri Apr 08, 2011 1:16 am
by Lafolie
I disagree with you both! :P I'm using bartbes' latest OOP invention: https://bitbucket.org/bartbes/slither/overview

I personally find it easier to use than both of the above. But eh, each to their own.

Re: Considering picking up Lua

Posted: Fri Apr 08, 2011 1:45 am
by BlackBulletIV
Slither looks pretty cool syntax wise, although I hate the funcName = function() stuff.

But indeed, each to their own.