Jump to content
  • Advertisement
Sign in to follow this  
tokaplan

Lua hesitations

This topic is 3668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I'm new to scripting, so I've been doing some pondering lately. SWIG seems to work just fine as a bridge between C++ and Lua, so I'm seriously considering writing the whole business logic in Lua. The way I see it, there are two major advantages of using a script in this context: - you don't have to recompile and rerun project to see result!!! - you don't have to expose the source of the engine to everyone involved in development. But when I imagine implementing the ENTIRE business logic code in Lua, I get a little scared, since - there's no syntax highlighting, so I have to browse through C++ class definitions to remember the name of the method I'm about to call!!! - there's no decent debugging of Lua script - there's no way to dereference a pointer to C++ type, so certain steps are necessary to avoid such situations - manual instantiation of every template implementation is a little tiresome I don't really care for the last two, but the first two points I've mentioned bother me a lot. So I though maybe some of you more experienced developers could share your thoughts on this. There's probably a lot I don't know. Thank you

Share this post


Link to post
Share on other sites
Advertisement
Lua strength are these:

-small footprint (~200k for VM, built GC etc.. )
-speed both interpreted and just in time compiled versions
-flexibility (easy to program in pure OO, functional or a mix, duck typing etc..)
-embedded nature ( designed to be integrated into applications )
-easy to sandbox ( can override unsafe functions in C code itself, due to its small and simple implementation )

Weakness in my opinion :

-lack of 3rd party support for debugging and IDEs

There are several IDEs for Lua which support debugging and syntax highlighting, they are commercial products though. I don't know of any freeware solution.

http://www.unknownworlds.com/decoda
http://www.itrango.com/vslua/index.html
http://www.quotixsoftware.com/qde_index.htm

I've tried ODE and Decoda, they are good. I've not tried vsLua, I'll give it a try soon. ODE is good at syntax highlighting and auto-complete, if your worried about that, give it a try, there is 30 day free period, same with Decoda.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Quote:
Original post by tokaplan
- there's no syntax highlighting, so I have to browse through C++ class definitions to remember the name of the method I'm about to call!!!

You can use a syntax-highlighting text editor like gvim or notepad++ to edit your lua code in. This will give you syntax highlighting for a huge number of languages including Lua.

Share this post


Link to post
Share on other sites
ddn3, thanks a lot, the editors you suggested are all great. I guess they are doing all they can, still I see no way I can automatically create an auto-complete file; QDE, for instance, wants it this way:

void ClassName:methodName( parameters )

I guess the only way to get a real auto-complete is to make a Lua IDE parse C++ headers. Maybe I'll find an IDE that does that ;) Otherwise all we can do is browse C++ headers manually.

Debugging is great though.

Thank you.

Share this post


Link to post
Share on other sites
Yeah creating auto-complete for C++ bindings is kinda tricky, since those bindings live inside C/C++ code vs in Lua script.

Solutions I've seen used in the past is to create a parallel interface in Lua through some automated scheme. Ie use a script to run through your C/C++ code look for Lua binding code, and create prototype functions in Lua for auto-complete, but those prototypes are only used to help the auto-complete. Kinda extreme but when your talking about several hundred C functions, it pays for itself quickly. ( This was on a commercial project and they were using their own custom IDE and scripting language but the same idea can be applied to Lua ).

Both Decoda and QDE are open to user suggestions, maybe you can submit it to their forum and see if they are willing to add something like that in the future (ie parse raw C/C++ headers and add it to the IDEs intellisense )

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!