Benefits of LUA Player?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Ghengis
Posts: 6
Joined: Fri Jun 09, 2006 1:59 am

Benefits of LUA Player?

Post by Ghengis »

Hey all,

I'm planning on starting my own homebrew game, which would be my first for the PSP. I wanted to ask both communities (LUA and SDK) to "sell" me on their platform. I have read the docs for both (well, not *all* the docs, but a lot of wiki stuff, forum posts, etc.) and I get the impression that a lot of people think LUA is not as capable, but the SDK is hard/complicated. If it matters:

-My background is mostly C++/Java
-I have done some embedded C programming
-I don't know LUA, but the syntax looks easy enough -- reminds me a bit of VB/Javascript (no declaration!)
-The game will be a 2D top-down space shooter, scrolling on both axes
-I'd like to implement the engine as 2D sprites mapped to 3D objects, so I can easily zoom the view in and out (hardware scaling, basically), but I don't know much about working with 3D
-I'll figure out sound and music when time permits; my priority is to get the engine going


Does anybody have a good reason to pick one platform or the other? Perhaps some pointers for good places to get started? I already have one or two Lua tutorials; my SDK references are less complete. I'm going to cross-post this to the other forum for maximum response.

Thanks in advance for any help!
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Just give both a go, I'd say. That way you'll find out soon enough which one suits you best. If you already have C experience, then the SDK might actually be easier initially - especially if you have little trouble getting it running. ;)

But Lua is very nice to work with too. From what you're trying to do though, I think you'll be better off with C++. But you might want to try to get something going first with 2D only, in which case you can use Lua, but you can also use SDL and develop on PC first, then port, or you can use one of the Vector libraries posted here, and so on.

Lots of options. If you experiment with 3D, you could first start with coding OpenGL on PC, then move from there to PSPGL on PSP, and then move from there to sceGu (native gu calls) on PSP.

I've been wanting to experiment with 3d, and the latter is my approach, greatly facilitated by the first of NeHe's examples having been converted to PSPGL recently (see other threads). I created my basic 3D routines on OpenGL on PC and ported those to PSPGL with ease. Great stuff.
Ghengis
Posts: 6
Joined: Fri Jun 09, 2006 1:59 am

Post by Ghengis »

Thanks! Those are a lot of excellent ideas. I had originally hoped to develop for PSP first, but starting on the PC might make my life a lot easier. I had thought about starting with 2D, then moving to 3D -- but I'm just lazy enough that my initial reaction to the idea was that I don't want to throw away a whole 2D game engine and start from scratch. The more I think about it, though, it's probably sound advice. Hrm... I've got to mull that one over a bit. From what you've said, though, I think my first move is going to be setting myself up with PSPSDK and seeing how that process goes -- if I don't have problems, I'll jump into C++ and see where it takes me. If I have problems with the toolchain, I'll give LUA a shot.

Thanks for all the hints!
impeachgod
Posts: 2
Joined: Sun Mar 12, 2006 5:47 am

Post by impeachgod »

Plusses of Lua:

Garbage collection
Support for functional programming
Dynamic typing

Minuses:

Slower execution speed due to it being interpreted
Ghengis
Posts: 6
Joined: Fri Jun 09, 2006 1:59 am

Post by Ghengis »

I don't consider garbage collection a plus in particular, and I don't know functional programming -- I've studied the concept, but I never learned how to *do it*. I also consider strong typing a strength, not a weakness. Can you tell I learned to program in C++?


Heh, seriously -- the big thing for me is class support. That, and I just found out about JGE++ (http://forums.ps2dev.org/viewtopic.php?t=5354) which sounds like exactly what I need. That, of course, is done in C++...
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Ghengis wrote:I don't consider garbage collection a plus in particular
Do you have a reaons, why you don't consider it as a plus? E.g. Java is very successful and one reason may be that it has a GC and the programmer doesn't have to take care when to release memory. A GC can be even faster than manual memory managment, because for complex applications your memory bookeeping code might be slower than if you use a GC: http://www.jwz.org/doc/gc.html
Ghengis wrote: Heh, seriously -- the big thing for me is class support.
There are many ways to use classes in Lua, see e.g. here: http://lua-users.org/wiki/SimpleLuaClasses
Ghengis wrote: That, and I just found out about JGE++ (http://forums.ps2dev.org/viewtopic.php?t=5354) which sounds like exactly what I need. That, of course, is done in C++...
Would be nice to write a Lua Player module for JGE++.
Ghengis
Posts: 6
Joined: Fri Jun 09, 2006 1:59 am

Post by Ghengis »

All good points -- yes I know GC is good for me, but I don't much care for brussels sprouts either. It's not that I *dislike* GC, it's just that I always saw it as a crutch to prop up poor coding. It's hard to get out of the "small scale" mindset from my undergrad days into the "enterprise" scope everybody seems to work on these days. For bigger projects, yes, GC has merit -- but how big is your PSP app going to get, realistically? If the scope is a handheld game, I have to imagine a halfway-competent C/C++ programmer is going to write a faster program than a similarly-talented LUA guy; that could be a misconception on my part.

I understand that Lua has "OOP support" in the loosest sense of the term, but then you can use "OOP" in JavaScript if you use a big enough shoehorn. When I look at LUA, I think JavaScript. Could I write a 3D platformer in JS? Probably, but it doesn't seem like a very good idea. Granted, LUA lets you make use of the PSP GU, if you really know what you're doing, but if you already know what you're doing, why not write in a compiled language and get the speed boost? At least that's my take on the subject.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

You won't find the silver bullet, which solves all problems. Of course, you can do anything in C++ or C and there are GCs for C, too, like the Boehm GC. And you are right, you can't implement a fast image rotate function in Lua, because it is too slow for single pixel manipulating low-level tasks like this. But in my experience writing game logic or e.g. a game menu in Lua requires much less code than the same in C (I've written Snake in C first for the PSP and then ported it to Lua) and it doesn't matter if a menu is displayed with 1000 fps or 100 fps. So if you need fast functions like image rotation, write it in C, but call it from Lua.

Strong typing is another thing. Languages like C/C++ and Java have strong typing and it might help to reduce bugs, but again, in my experierence the drawback is that it makes things more complicated for the programmer. Programmer cycles are expensive, CPU cycles are cheap.

A good article from an Amazon programmer, which reflects my experience, too: http://www.cabochon.com/~stevey/blog-ra ... yping.html

But don't believe me or other people, try it yourself: Write a small program in Lua and the same in C or C++ and compare the runtime performance and your productivity as a programmer with both languages.
Ghengis
Posts: 6
Joined: Fri Jun 09, 2006 1:59 am

Post by Ghengis »

That's a really good suggestion -- when I have time to set up the C++ toolchain and install LUA player (more programmer cycles!), I'll try just what you said. Of course, having to *learn* LUA costs cycles too ;-)
Post Reply