6 ms·
Interesting for me to know that Lua has been used seriously for game development. What are the main limitations?, how come people aren't developing more in Coro
by pacomerh 15y ago
Interesting for me to know that Lua has been used seriously for game development. What are the main limitations?, how come people aren't developing more in Corona rather than straight objectiveC. I'm guessing the Corona environment itself is the limitation?.
- malkia 15y agoYou just said that you've just learned about lua used in games, and then directly propose Corona as the only place where you can use lua. You can embed yourself lua, and that's it's power. It can go down to 30-40kb (without parser), and run on PS3 SPU chip (256kb memory). It does not use any globals, all goes through a state structure, so you can have multiple runtimes (and different ones, HavokVM, lua reference, luajit) if you want at the same time. Don't get me wrong, Corona is cool, but there is also moai, and tons of other toolkits, and hundreths of other games that are using it - for scripting, ui layout, configuration, many other things.
- Derbasti 15y agoLua is pretty minimalistic. There are few batteries included. The standard library is very basic. There is no native object system, though implementing one is trivial. That said, I friggin love Lua for its flexibility and transparency. Once you grok its few basic mechanisms, everything else just falls in place. In contrast, understanding Ruby or Python is a lot more difficult since the languages themselves are a lot more complex. In fact, if I were to teach programming, I would teach it using Lua. Implementing your own object system is increadibly instructive. Learning about coroutines and lambdas is, too. And Lua is still small enough to just read its source when in doubt. It's bytecode consists of just a few dozen instructions. Honestly, Lua is a marvellous language and I just love to use it!
- RegEx 15y agoDo you have any recommended resources for programmers looking to pick up Lua?
- anonymoushn 15y agoProgramming in Lua seems to be the best choice, but mostly by virtue of the very small number of coices. It was most recently printed in 2006, but there were few breaking changes since then, and you won't run into them very often. To be honest, I learned it using only the tutorial here: http://lua-users.org/wiki/LuaTutorial http://lua-users.org/wiki/LuaTutorial and google.
- telemachos 15y agoRoberto Ierusalimschy's Programming in Lua, 2nd Ed. is an absolute gem. Well written, concise and very authoritative (he's one of the language's co-creators). One thing worth knowing though: he's working on the 3rd edition (updated for Lua 5.2), though I'm not sure how soon that is expected. The first edition is online, if you want to get an idea what it's like: http://www.lua.org/pil http://www.lua.org/pil. In addition, the language's refrence manual is freely available online as well. Depending on how you learn, that would get you started very quickly. (It's a small language and very much follows the principle of least surprise - except for indexing arrays from 1, but you get used to that.) http://www.lua.org/docs.html http://www.lua.org/docs.html has the full reference manual for 5.1 and 5.2.
- Derbasti 15y agoSeconded, the book is friggin awesome, if a bit dry. It is written for an experienced programmer though. Personally, I learned object orientation through this book. I knew basic OO before, but this book really explained it to me.
- moonchrome 15y ago>In fact, if I were to teach programming, I would teach it using Lua. Implementing your own object system is increadibly instructive. Learning about coroutines and lambdas is, too. And Lua is still small enough to just read its source when in doubt. It's bytecode consists of just a few dozen instructions. If these things appeal to you check out lisp (clojure is my personal recommendation)
- BystanderX 15y agoLua itself can stand pretty well, especially with LuaJIT2. That said, I'm starting to learn Lisp right now (Clozure/OpenMCL), and coming from primarily Lua development in the last two years, it seems much less like the leap many play it out to be.. Instead, it has seemed more like simply stepping from a clean, compact room into a large, similarly clean and smooth room but with depth you hadn't imagined before. Well, that and learning Emacs compared to ST2 is a bit of a step at the same time.
- Derbasti 15y agoI know a bit of eLisp and I quite like it. Frankly, it's not that Lisp syntax is bad (it's wonderful), but most popular languages have a C-derived syntax. For teaching to non CS-types, the target is probably a C-like language and I guess Lua is closer to that than Lisp.
- ansible 15y agoIf I were using a Lisp these days, I'd really miss the Lua table. Lisp is built around cons cells and the linked list. But it has seperate containers of various types. Lua is built around the Lua table, which can function as a list, array, and dictionary/hash table. You can then build any other data structure from tables easily. With a metatable, you then also get read-only tables, objects and classes, and more. Now if someone were to design a modern Lisp based around tables...
- moonchrome 15y ago>Now if someone were to design a modern Lisp based around tables... Check out clojure - advanced data structures/primitives + immutability(functional programming)
- gruseom 15y agoLua is pretty minimalistic. There are few batteries included. The standard library is very basic. To what extent does its easy C interop make up for this?
- dyselon 15y agoIt helps quite a bit. It's really easy to write a glue layer between Lua and whatever C library you want. The downside is that you still have to actually write that glue. It should probably be noted that Lua gets along less well with C++, so that glue is a bit harder to write for C++ libs. There are tools that will automatically generate that glue for C++, but I'm not familiar with them.
- BystanderX 15y agoAs Dyson said, it's fairly easy. LuaJIT2's ffi also makes it a lot quicker.
- mangodrunk 15y agoI tried to get into Lua, but with issues with installing LuaRocks and the library I was using, LuaFileSystem, I wasn't all that impressed. This could most likely be the library I was using or I didn't give it enough time. So, could you go into more detail about Lua's flexibility and transparency and what is it that you grokked about the few basic mechanisms? What about library support? It seemed that LuaRocks was the most popular module manager and it didn't seem to have that many libraries, and some seemed to be orphaned. My question is if you have experience with this or is this a mischaracterization of things? I wanted to start out using Lua as a scripting language which may not be a good fit, but it seemed more compelling than other languages I was looking into.
- forrestthewoods 15y agoLua is indeed widely used in games. The plus is that it's a very simple language to pickup and anyone on the team can learn to use it. The downside is that anyone on the team can use it. :) Memory is an extremely rare commodity in embedded systems and Lua loves to gobble it up. Consistent perf in video games is crucial and the Lua garbage collector can be brutal in this regard. Newer versions of Lua support incremental garbage collection but it's quite realistic to dedicate 2-3 milliseconds of every frame to garbage collection. Yuck. (16ms = 60fps, 33ms = 30fps) Lua is trivial to implement into an existing engine. Lots of iOS engines heavily rely on Lua. Large games devs don't want to become reliant on those middleware engines. It can take them many months to update to latest iOS sdk. It took several popular engines 6+ months to integrate the in-app purchase SDK update. Havok, owned by Intel, purchased Kore and turned it into Havok Script. Havok Script is a virtual machine that runs a "Lua compatible" language. It is extremely fast. Ridiculously faster than straight Lua. It also has full debugging support and you can trivially step through a call stack that bounces between C++ and script. Havok middleware is not known for being cheap.
- pjin 15y agoluajit2 in interpreter mode is also very fast, originally written in x86 (Mike Pall has probably finished the arm port by now). But I've never heard of any benchmarks between the luajit2 interpreter v. havokVM, that would be interesting to see.
- tomlu 15y agoKeep your eyes peeled for a port of the LuaJIT interpreter to the consoles. From recollection it's two or three times faster than straight Lua.
- emmelaich 15y agoI think you'll find many if you look. It occupies a nice slot between the speed and control of C and the ease (and slowness) of python, java etc. Codea, app development in iPad for iPad uses lua. It was recently mentioned on HN. Computercraft, a mod for minecraft embeds lua in minecraft for you to program. Not a direct use of lua in gaming, but cute!
- NickPollard 15y agoLua is used largely in AAA development. Most famously, it powers the UI for World of Warcraft, and users are able to write their own complete UIs in Lua. Many other games use it for scripting. When I worked at Sony, we were using it on quite a few PlayStation games.