PDA

View Full Version : Thoughts on Lua



yaustar
July 13th, 2006, 12:38
Since so many members here have picked it up recently, I thought I share my thoughts on Lua itself and hear other opinions on it.

Lua is a scripting first and foremost and should be treated as such. The syntax is meant to be easy to learn and uncomplicated. I have no real problems with this (even though I would kill for type checking) but I find that a lot of errors by myself and others is the way that scripting languages can create variables out of thin air and mostly by misspelling the variable/function name.

Also due to its simplicity, it makes the entire language easy and quick to learn but at the same time it doesn't have much support for structured programming forcing the programmer to do a lot of work him/herself. This is fine for scripts that perform a custom action on a tile in a game but is horrendous for trying to produce a game out of it which leads me to my next point: LuaPlayer.

LuaPlayer is a solid Lua framework for the PSP(Open source too which is great) but it does have a distinct flaw, not with the program itself but how people approach to scripting with it.

With LuaPlayer, someone can get something on the PSP screen extremely quickly (literally in a matter of minutes) and start moving it round the screen. This then starts to evolve into starting to create a game and then the project is started. Sounds great doesn't it? Here lies the fatal flaw, the user has just skipped learning the fundemental basics of programming and jumped straight into making a game (nothing like jumping off the deep end). While/For loops, if/switch statements, variables, functions, parameter passing, return values, commenting/programming styles, arrays, data structures, code reuse.

The problem is that using Lua with Luaplayer is that it falls in between a GameMaker program and Programming Language. It has all the ease of creating a simple application as with all GameMaker like programs but without any of the management that goes on behind the scenes. GameMaker programs has always had high level scripting (e.g. if A collides with B, destroy B) which Lua and LuaPlayer do not forcing the programmer/scripter to program this behaviour themselves, something they wouldn't know how to do effectively without programming basics.

A final note to all LuaPlayer scripters, there is a huge brick wall for all of you that have started recently. I be very interested to see who hits it (and how), who avoids it by knowing its there and who breaks it and how.

Good Luck.

MasterChafed
July 13th, 2006, 13:24
My personal reactions to lua are almost all positive. I mean, sure there are things such as you posted like the collsion deleting etc. And i am still trying to figure that out. But i really love it, it is very fun to learn and very easy to use. It is very limited in options however, such as music, wav files crash it so they can only be used as sound fx and mod formats can't seem to be played if they are larger than 1mb. It a pain in the butt, but i still enjoy it.

yaustar
July 13th, 2006, 14:03
You have to remember that Lua and LauPlayer are two different things. One is a language and the other is a framework. The limitations you mention are LuaPlayer's restrictions not Lua's.

chaos-is-me
July 13th, 2006, 15:19
I started learning Lua the other day, just out of boredom. It's pretty fun to learn and I have made a couple of little apps that don't really do anything but just make me feel clever, haha. I want to try and make a game eventually but for now i'm content with just playing around with it and learning the basics.

Crimson_Lotus
July 13th, 2006, 16:27
Lua is basically designed to allow programmers to add features to a program without having to "re-do" the program entirely. I also believe that it is designed, so that programmers working together will have greater comprehension.

It has a small set of features and functions designed so that they can be extended to differant purposes. Barriers may exist in certain stages of development, but by working hard and structuring the code correctly (like LuaPlayer demands) I believe they can be amounted to hurdles that can be passed but are delays in production. Lua does lack some of the values that well polished languages contain and when it is working off the Luaplayer especially.

I do not believe Lua is most attributed to being a scripting language but rather an extension language, although it could be seen as both.

yaustar
July 13th, 2006, 17:07
You are right, it is used so that programmers, level editors etc can change the functionality or unique events of the program without rebuilding or recompiling (a time consuming job on large projects) and it does a fantastic job of it. However at the same time, I don't think it is suitable for large scale games compared to other languages such as Python because it lacks the features needed at the base/langauge level.

I don't think LuaPlayer 'demands' anything, all it provides are high level API function calls to the PSP's hardware as far as I can tell. It doesn't supply any structure in the same way as the DSLua framework does (eg Sprites).

For example, I can write up the entire program in a while loop rather then splitting it up in functions and it will still work the same way. Although you can do this with other languages, structuring the code/objects etc seems to be more tedious in Lua then in other languages I am using. Currently, I am thinking about designing a vector/stack/list/queue like structures in Lua to disprove/prove this fact.

Lua is definitely the most basic scripting language I have come across. It is possible that I am having a little more trouble working with it as I come from an OO background rather then a procedural and Lua is very procedural (although OO design can be 'hacked' in with metatables).

Whether Lua is or is not a scripting langauge, I am having trouble seeing the fine line that seperates the sub sets of languages in this area so I just group them as such since they are (generally) interpreted rather then compiled which are generally defined as a script.

Crimson_Lotus
July 13th, 2006, 17:38
I don't think LuaPlayer 'demands' anything, all it provides are high level API function calls to the PSP's hardware as far as I can tell. It doesn't supply any structure in the same way as the DSLua framework does (eg Sprites).

For example, I can write up the entire program in a while loop rather then splitting it up in functions and it will still work the same way. Although you can do this with other languages, structuring the code/objects etc seems to be more tedious in Lua then in other languages I am using. Currently, I am thinking about designing a vector/stack/list/queue like structures in Lua to disprove/prove this fact.

Lua is definitely the most basic scripting language I have come across. It is possible that I am having a little more trouble working with it as I come from an OO background rather then a procedural and Lua is very procedural (although OO design can be 'hacked' in with metatables).

Whether Lua is or is not a scripting langauge, I am having trouble seeing the fine line that seperates the sub sets of languages in this area.

When I say demands, I am mostly talking about the limitations of the lua player. While few, the Luaplayer still has its own quirks. Indeed lua is a very light language, which is related to its function. The reason I see Lua as an extention language is how the language is very "stretchable" and usable in many cases in other games. It is often an Interpreter rather than the whole of a programs language. World of Warcraft for example, uses it as such.
:)

edit: I figured you would tack on some stuff about that in your edit;)

yaustar
July 13th, 2006, 17:43
That is fine, I don't disagree that point, I have seen it being used effectively in projects at University. My main concern is that some are taking it as a primary language here at DCemu (with the abundance of LuaPlayer games) rather then what it was ideally designed for. Or it could be that I am just paranoid and they will eventually ditch Lua as a primary language and learn something else instead.

edit: Sorry about that, I keep having half thoughts :p

Crimson_Lotus
July 13th, 2006, 18:38
That is fine, I don't disagree that point, I have seen it being used effectively in projects at University. My main concern is that some are taking it as a primary language here at DCemu (with the abundance of LuaPlayer games) rather then what it was ideally designed for.

I agree, and your point is valid that it is not being used in its "designed for" manner. The way the code is used is still effective though, also because of the way it is designed. Lua being a dynamically typed language intended for use as an extension or scripting language. When coders here are using it, it happens to be used in a scripting manner to perform their tasks. In general, Lua provides flexibility in the form of meta-features that can be extended as a programmer wants. Here these meta-features are each part of a game engine. In my mind and at a technical standpoint, the Lua coders are using Lua exactly how it was designed, to maintain parts of a program or add onto it. They are just maintaining each part and falling together to form the game.

yaustar
July 13th, 2006, 18:51
True. As you said earlier, Lua is a simple language and I just don't believe it provides enough base level functionality to produce a large scale game compared to other dynamically typed languages such as Python. As the code base hits a certain size, maintainence becomes a logistical nightmare but at the same time, I have never taken on a large scale procedural language project so I may have a naive point of view on this.

Crimson_Lotus
July 13th, 2006, 19:20
True. As you said earlier, Lua is a simple language and I just don't believe it provides enough base level functionality to produce a large scale game compared to other dynamically typed languages such as Python. As the code base hits a certain size, maintainence becomes a logistical nightmare but at the same time, I have never taken on a large scale procedural language project so I may have a naive point of view on this.

Lol same here;). Of course we both have differant point of views on the subject. In a sense, I believe we are both correct in some manner.:)