Page 1 of 2
Interesting Lua Fact...
Posted: Fri May 08, 2009 11:49 am
by Falco Girgis
So I have been playing around with Lua at work. I'm compiling everything myself to my own static library (rather than downloading a precompiled one). So APPARENTLY I didn't add the lexical analyzer or parser when I built my static library. So instead of bitching at me, it turns out that Lua didn't care.
Lua was designed so that the lexer/parser could be taken out at a 35% size decrease, which is totally beneficial for embedded systems (such as Dreamcast, PSP, and iPhone).
So I was freaking the fuck out wondering why my simple luaL_dostring() and luaL_dofile() didn't do anything. I was too lazy to fetch the error code and string for awhile. When I finally got around to it, I was told "parser not loaded."
Once again, Lua is too eloquent, intricate, and beautiful for me to handle.
What the official Lua site has to say about it:
http://www.lua.org/notes/ltn002.html
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 12:00 pm
by K-Bal
Nice. 24k for a complete scripting language

Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 12:51 pm
by M_D_K
Very nice!
Here is another interesting lua fact...it has multi line comments. I seriously thought I was stuck doing --This is a comment.
Although the multi line is more key presses then that so only good for nice big rants about how Peter broke the code
Code: Select all
--[=[
ZOMG Multiline
COMMMMMENT!!
--]=]
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 2:09 pm
by Falco Girgis
Actually, Peter has been using multi-line comments in our code for quite awhile...
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 2:35 pm
by M_D_K
GyroVorbis wrote:Actually, Peter has been using multi-line comments in our code for quite awhile...
Sorry I must have missed the memo

Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 3:49 pm
by dandymcgee
M_D_K wrote:Very nice!
Here is another interesting lua fact...it has multi line comments. I seriously thought I was stuck doing --This is a comment.
Although the multi line is more key presses then that so only good for nice big rants about how Peter broke the code
Code: Select all
--[=[
ZOMG Multiline
COMMMMMENT!!
--]=]
Awesome!
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 5:27 pm
by davidthefat
You know there are tons of Homebrew for psp all programmed in LUA?
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 5:32 pm
by M_D_K
davidthefat wrote:You know there are tons of Homebrew for psp all programmed in LUA?
LuaPlayer is like the gamemaker of the PSP homebrew scene. The system is solid and easy to use, but too many people releasing pieces of crap made with it.
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 6:58 pm
by sparda
M_D_K wrote:Here is another interesting lua fact...it has multi line comments.
Nice, I wasn't aware of Lua's multiline comment ability. Although, I have to say, that Lua comment-token and its delimiter are ugly as a hairy butt. Compare
Code: Select all
--[=[
ZOMG Multiline
COMMMMMENT!!
--]=]
To Python's:
Code: Select all
"""
ZOMG Multiline
COMMMMMENT!!
"""
I say python wins
GyroVorbis wrote:Lua was designed so that the lexer/parser could be taken out at a 35% size decrease, which is totally beneficial for embedded systems (such as Dreamcast, PSP, and iPhone).
By my calculation if there is a 35% reduction, that means that the default Lua setup would be roughly ~35k. Is it really that much? I mean, when the Dreamcast has 16 + 2 + 8 MBs and the PSP has 32MB of memory, 35k footprint seems a rather negligible amount still (To this day, I can't believe the Dreamcast has less dedicated memory than something as small as the PSP or iPhone). The iPhone is outrageous, with 128MB DRAM, so nothing to worry about there. So for elysianshadows on Dreamcast, I say compile the whole thing, and luaL_dostring()
<Lame excuse for a jokez>
Those lua function names prompted me to this hilarious (did I mention hilarious?) joke (drum rolls please):
While you're at it, call luaL_dokindall( nicely ) and luaL_doMar( gently ). I'll call both luaL_doavan( gently ) and luaL_doM_D_K( grab_his_boobs ). I have to be careful, as the latter has a runtime complexity of O( n^(n) * factorial(factorial(factorial(n))) )
</Lame excuse for a jokez>
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 7:43 pm
by LeonBlade
Wow, LuaPlayer looks pretty cool, didn't know about it.
But I agree with the Game Maker comparison...
Re: Interesting Lua Fact...
Posted: Fri May 08, 2009 9:17 pm
by davidthefat
M_D_K wrote:davidthefat wrote:You know there are tons of Homebrew for psp all programmed in LUA?
LuaPlayer is like the gamemaker of the PSP homebrew scene. The system is solid and easy to use, but too many people releasing pieces of crap made with it.
LOL I actually agree to that
Re: Interesting Lua Fact...
Posted: Sat May 09, 2009 7:22 am
by K-Bal
sparda wrote:
By my calculation if there is a 35% reduction, that means that the default Lua setup would be roughly ~35k. Is it really that much? I mean, when the Dreamcast has 16 + 2 + 8 MBs and the PSP has 32MB of memory, 35k footprint seems a rather negligible amount still (To this day, I can't believe the Dreamcast has less dedicated memory than something as small as the PSP or iPhone). The iPhone is outrageous, with 128MB DRAM, so nothing to worry about there. So for elysianshadows on Dreamcast, I say compile the whole thing, and luaL_dostring()
That is just the footprint size. It will take a more serious amount of RAM when you start compiling lua files on the fly.
Re: Interesting Lua Fact...
Posted: Sat May 09, 2009 1:13 pm
by sparda
K-Bal wrote:compiling lua files on the fly
What do you mean? To my understanding, when you integrate Lua into your C/C++ project (i.e. using lua functions in your C/C++ program), you compile the Lua intepreter/vm directly into your app. Then the Lua scrips are merely ran, not compiled, from within your app. Then again, I could be wrong as I'm not familiar with lua at all, but the concept is general.
If you can dynamically allocate objects in lua (I don't know if that is possible), then perhaps its footprint would grow. That's one possibility I see. I'm sure lua would have a garbage collector in that case; which would also increase memory usage. This has nothing to do with compiling scripts, that is not what interpreters do.
So K-Bal, maybe you meant something else? Clarify.
Re: Interesting Lua Fact...
Posted: Sat May 09, 2009 3:46 pm
by K-Bal
If you load a .lua file it gets compiled and than executed.
You can also use precompiled lua files using the luac.exe.
Just read the article Falco posted, it is explained in there.
Re: Interesting Lua Fact...
Posted: Sat May 09, 2009 4:32 pm
by Falco Girgis
sparda wrote:K-Bal wrote:compiling lua files on the fly
If you can dynamically allocate objects in lua (I don't know if that is possible), then perhaps its footprint would grow. That's one possibility I see. I'm sure lua would have a garbage collector in that case; which would also increase memory usage. This has nothing to do with compiling scripts, that is not what interpreters do.
... "dynamically allocate" in Lua? Dude, Lua is a scripting language. When can you STATICALLY allocate? XD