Considering picking up Lua

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Considering picking up Lua

Post 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!)
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Considering picking up Lua

Post 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. :)
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Considering picking up Lua

Post 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 :)
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Spade
Prole
Posts: 4
Joined: Wed Apr 06, 2011 1:39 pm

Re: Considering picking up Lua

Post by Spade »

Concerning OOP then, how difficult is it to get some sort of class system going?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Considering picking up Lua

Post 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 :)
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Considering picking up Lua

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Considering picking up Lua

Post 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.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Considering picking up Lua

Post 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?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Considering picking up Lua

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Considering picking up Lua

Post by BlackBulletIV »

Slither looks pretty cool syntax wise, although I hate the funcName = function() stuff.

But indeed, each to their own.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests