JohnnyStarr
Wizard


Group: Members
Posts: 823
Joined: Feb 14, 2009
|
#1 id:27991 Posted Jul 1, 2009, 4:34 pm
|
So, i've been looking into Lua and what not, but it appears (to me) that you can just as easily use python to embed as a scripting language for your mud, now, i dont have much experience with python, and none with Lua, but what you guys think about it? From what i know (which aint much) is that python allows implicit OOP as where with Lua (from what i've read) does not, but you can simulate it using features. It seems that Lua is more designed to work with C, but i personally like the idea of python. anyway, just wondering, not trying to sound like i know more than anyone.
|
.........................
"It's not the daily increase but daily decrease. Hack away at the unessential." - Bruce Lee
Southlake Window Cleaner
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#2 id:27992 Posted Jul 1, 2009, 4:38 pm
|
Lua is probably easier to do that with, actually, and OO paradigms can be used even with C. Some languages may just make it easier to do this.
I personally like Python better, though.
You can expect to hear from David on this subject shortly. :P
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
Last edited Jul 1, 2009, 4:43 pm by Runter
|
|
|
|
JohnnyStarr
Wizard


Group: Members
Posts: 823
Joined: Feb 14, 2009
|
#4 id:28019 Posted Jul 1, 2009, 7:42 pm
|
quixadhal said:Yep... I like the python language better, but I've heard that lua is much simpler to embed (easier to transfer data in and out of the sandbox). I haven't actually DONE that, so it may simply be a rumor. :)
i am not authority on the subject, but everything i've read on it dosn't look simple at all, python however seemed (to me) to be more straight forward than Lua, maybe thats because i am very comfortable with ruby, maybe the tutorials i read were crummy, i dunno.
|
.........................
"It's not the daily increase but daily decrease. Hack away at the unessential." - Bruce Lee
Southlake Window Cleaner
Last edited Jul 1, 2009, 7:50 pm by staryavsky
|
|
|
|
|
|
David Haley
Wizard


Group: Members
Posts: 6,912
Joined: Jun 30, 2007
|
#7 id:28038 Posted Jul 1, 2009, 11:02 pm
|
Lua is trivial to embed into C and extend with C. Python is relatively easy but still more difficult than Lua; this is perhaps to be expected because Lua was designed to do this, to a large extent.
What seemed straightforward in Python and complex in Lua? Just curious.
The best Lua tutorial I know of the "Programming in Lua" book, the first edition of which is available for free online at lua.org.
I'm actually not sure I'd recommend Lua to a newbie because you need a few more things to get it working. The standard libraries are quite small. I believe that Lua is better for embedding and for various reasons I prefer it as a language anyhow, but if you don't know how to take advantage of its strengths then you might as well not use it.
One of Lua's biggest strengths is its simplicity, with extremely clear extension semantics with metatables etc. This means that you can very easily make the language behave to a large extent as you want it to. Python gives you similar flexibility in some places, but the documentation is far inferior and involves tracking things down in various different places to piece together an answer.
Python is hardly a "bad" choice, though: EVE Online uses it extremely heavily not just for scripting but also to implement the vast majority of their game logic.
|
|
|
|
|
MaineCoon
Fledgling

Group: Members
Posts: 9
Joined: Sep 4, 2007
|
#9 id:28958 Posted Jul 15, 2009, 7:05 pm
|
Is the scripting language for yourself, for your coders, or for any builder to be able to add behavior?
If it's intended for 'any builder to be able to add behavior' then you want a language that is very easy for people to pick up. It's hard enough teaching people about variables and simple if-then conditional blocks of code; trying to teach them to use a consistent indentation method is just compounding your headaches.
That is why you should not use Python as an embedded scripting language.
|
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#10 id:28959 Posted Jul 15, 2009, 7:10 pm
|
MaineCoon said:Is the scripting language for yourself, for your coders, or for any builder to be able to add behavior?
If it's intended for 'any builder to be able to add behavior' then you want a language that is very easy for people to pick up. It's hard enough teaching people about variables and simple if-then conditional blocks of code; trying to teach them to use a consistent indentation method is just compounding your headaches.
That is why you should not use Python as an embedded scripting language.
I disagree. I think enforcing indention could be an extremely good thing for programmers (that's what they will be) who have no concept of the usefulness of writing maintainable, uniform code.
That being said, I'm not a python fan.
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
|
|
Idealiad
Sorcerer

Group: Members
Posts: 389
Joined: Jan 28, 2007
|
#11 id:28960 Posted Jul 15, 2009, 7:14 pm
|
I agree with the spirit of MaineCoon's comment. If you want something easy for builders to pick up I would get rid of scripting altogether, and use OLC-defined templates for 'scripting'.
Also, as a beginning programmer, indentation in Python is the least problematic thing I have to deal with. ;D
|
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#12 id:28961 Posted Jul 15, 2009, 7:33 pm
|
Well, I don't think the debate of script or not to script will be settled today. I'll just say this---If you are going to script then python is a powerful, easy, intuitive choice after the fact.
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
|
|
MaineCoon
Fledgling

Group: Members
Posts: 9
Joined: Sep 4, 2007
|
#13 id:28962 Posted Jul 15, 2009, 8:18 pm
|
Runter said:I disagree. I think enforcing indention could be an extremely good thing for programmers (that's what they will be) who have no concept of the usefulness of writing maintainable, uniform code.
You're welcome to disagree, however - having taught many newbies learning to program for the first time, I've discovered there's a huge difference between enforcing indentation, and actually getting users to understand when to use it and why. That's a whole lesson in itself, after you're done explaining what a variable is and what 'if/else' does.
|
Last edited Jul 15, 2009, 8:26 pm by MaineCoon
|
|
|
|
David Haley
Wizard


Group: Members
Posts: 6,912
Joined: Jun 30, 2007
|
#15 id:28976 Posted Jul 16, 2009, 12:51 am
|
It is basically impossible to automatically indent code when using a whitespace sensitive language. Consider the following lines of code:
Code (text): 1
2
3
4
5
6
7
8
9 |
def f(x, y):
if x > 2:
x = x + 1
x = x * y
return x
|
The example is contrived, but the point is made perfectly. Where do you put the line x = x * y? Do you put it inside the if block or not? In other words, do you assign x*y to x only when x > 2, or always?
Languages like Python basically have to be indented manually: you can sometimes "guess" as to what must happen (for example, a return statement must finish a block, and an if statement must start a new indentation level) but in general you cannot always infer where things must be indented.
Python's whitespace policy is actually one of people's biggest beefs with the language. It's extremely easy to make mistakes because you happened to forget to indent something; it's much harder to make that kind of mistake in a language that enforces explicit blocks.
(Also, I personally find that having block terminators makes a far better visual separation, and makes it easy to see where blocks start and stop, and especially which starts/stops correspond to which stops/starts.)
|
Last edited Jul 16, 2009, 12:51 am by David Haley
|
|