![](templates/Classic/images/spacer.gif) |
Dharkael Enchanter
![](images/avatars/9583916094231d31d8f24f.png)
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Tue Dec 25, 2007 10:10 am
Lunatic Python: Python in Lua, Lua in Python |
Lunatic Python: Python in Lua, Lua in Python
==============================================
Okay, I think that having Lua as a native scripting language to CMUD is the best thing about CMUD so far.
It's small, fast , easy to learn, and by all indications a very powerful language.
Power that will no doubt be realized as the CMUD/Lua integration is stabilized and our userbase develops a greater facility using Lua.
One of the best things about Lua is that it's extendable, meaning we don't have to be satisfied with the functionality the host app(CMUD) provides
nor the base functionality the standard Lua libraries provide.
We can download and install libraries to extend Lua's and CMUD's functionality to provide socket operations,XML processing, whatever.
And failing that those of us that have the ability and the inclination can write our own and provide it to the others, not so inclined or able.
With all this in mind I've had a look around and found that compared to some other languages like Python or Perl for example,
Lua's libraries are less extensive (:p) and aren't really "Out of the box" which can be quite a pain for the general user.
Contrariwise Python seems fully loaded in this area.
This is where Lunatic Python comes in.
This package allows 2 way communication between Lua and Python, you can call Lua code from within Python and
(more importantly for us) you can call Python code from Lua, which means of course you can take advantage
of all those great Python libraries out there, or if you prefer Python you can write your own Python modules
Leaving most of the logic in Python and use Lua as a glue language to access your Python modules.
The homepage for this little gem is http://labix.org/lunatic-python
Naturally it doesn't work "Out of the box" you have to compile it yourself and link it to your version of Python and your Lua version.
I'm no avid C/C++ programmer I gave it up years ago, but I was able to make it work.
Using a MS VC++ compiler and this great little build utility I found call Scons (check it out).
Scons can be found here http://www.scons.org/
The Lunatic Python src does come with a little Python setup script that should have used Python's builtin Extension library
and your installed C/C++ compiler to properly compile and install everything for you, but of course It didn't work like that.
some small changes in how one writes a Lua extension since the code was written required some changes.
And the Python Extension module was kinda picky about the user having the same compiler that the Python library was compiled with.
Rather than try to fight that I found Scons and without out too, too much trouble was able to get everything sorted using the MSVC++ compiler I did have installed.
In the end I was able to get everything sorted and I have been able to call Lua code from Python and Python code from Lua
specifically from CMUD.
Anyways I think I might not be the only one to find this interesting so I recommend taking a look.
If anybody is interested and so requests I would be willing to give a play by play of what It took for me to get it working.
Enjoy |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
![](templates/Classic/images/spacer.gif) |
Fang Xianfu GURU
![](images/avatars/1763170544a2093e7e85da.gif)
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Dec 25, 2007 7:52 pm |
On the one hand, I love the super-extensibility that this sort of thing will add. But on the other hand, I hate using an intermediate language - if you want to code in Python, for example, then code in Python and leave Lua out. Eventually the zs object will be available to all scripting languages via WSH, negating the advantages of Lua in that area.
Still, definitely a curio worth taking a look at. Thanks for the link. |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|