Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Which script language is best?

Which script language is best?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kaervos   USA  (11 posts)  Bio
Date Mon 17 Nov 2008 12:18 AM (UTC)
Message
I've been using MUSHclient for some time now, and have exclusively used Lua script, as there seems to be more info on it in MUSHclient's help files, and it seems to have the most straightforward syntax.

However, I have noticed that most people seem to dislike Lua, and prefer other script languages. This makes it difficult for me to get help with my scripting needs, and also prevents me from using plugins and scripts that others post (as most of these are not written in Lua).

So, I have two questions:
1) Why is Lua generally considered to be inferior to other scripting languages? I haven't encountered any real problems with it.

2) Should I decide to switch over to another scripting language (I've been thinking about VBscript, specifically), about how difficult would it be to convert my existing scripts? I've got about 740 lines, but a lot of that is just extra spacing and comments to improve readability; I'd say maybe half of it is actual code, if that.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #1 on Mon 17 Nov 2008 12:30 AM (UTC)
Message
Lua is kind of the new kid on the block, and has been adopted by the gaming industry as a free scripting language to incorporate into their games, for instance, World of Warcraft. I guess it's easy to see some 'it's just a toy' stigma attached to it.

Many mudders also have real life jobs that are technical in nature, and they leverage that; what they know in the real world, to help them with their gaming. IT types that script in perl or vbscript or php for a living can very easily stick to what they know.

It's really a matter of familiarity. Which ever you're most comfortable with.


Although, in the case of MushClient, since Nick is promoting the language heavily, and doesn't have the restriction of Binary Compatibility like the other ActiveX language engines have, Lua's been made more accessible. For Example, doing anything with StyleRuns is simple in Lua, and a processor intensive kludge with the ActiveX languages. :)


The forums here are active, and Nick and David are very helpful with Lua questions... perhaps the "most" people you talk to, aren't the best ones to answer your questions. :)
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Mon 17 Nov 2008 03:05 AM (UTC)
Message
From a technical perspective, Lua is a very clean language with clear, unambiguous syntax, and relatively simple semantics. This means that it is quite easy to learn, especially if you already know how to program. Its underlying architecture is also very simple, which means that it is almost too easy to extend and embed in other programs, which is what Nick has done with MUSHclient. Unlike other languages, MUSHclient talks directly to the Lua interpreter -- it doesn't have to go through some ActiveX interface that lies in between the host (MUSHclient) and the scripting language.

If there is a pain point with Lua, it is the relatively small community compared to, say, Python. The Lua community is extraordinarily competent and helpful -- the language authors themselves are fairly active on the mailing list -- but a small community means a small set of standard libraries. In fact, part of the problem is that (by design) there are no standards imposed for many things.

Object orientation is an example of this. Lua provides the mechanisms to implement any number of object orientation paradigms (inheritance-based, prototype-based, ...). This is wonderful if you need to set up your system based on specific needs. This is kind of terrible if every library uses its own convention: it is much harder to make the libraries talk to each other, because there is no common, standardized encapsulation mechanism.

The other issue is that you need to hunt around a bit more for libraries to accomplish common tasks in Lua. For example, there is no standard, provided way of talking to files beyond simple I/O: there is no mechanism for listing the contents of a directory, getting a file's extension, and so forth. Of course, this can be (and has been) achieved with libraries, and in this case there is a quasi-official filesystem library called "LuaFileSystem", but for other tasks it might not be so clear.

What is Python's advantage over Lua? IMO, it is the rich library and standardized mechanisms. Lua's advantage is its simplicity, small footprint and efficiency (although Python is making very big strides with JIT compilation). There are several things I don't really like about Python but I'm not sure they're very relevant right now.

But the library problem can be fixed. My personal gripe with Lua is the lack of compile-time type verification. Of course, it is kind of inappropriate for me to have this gripe, because this is not something Lua wants or tries to do. (Python has the same problem, as does pretty much any dynamically typed language.)

In my honest opinion, VBScript is inferior in almost every way to languages like Lua or Python. I would never recommend that somebody spend much time on VBScript unless they actually had to (as I have to when I want to write Outlook macros, for example).


Let me try answering your questions specifically now:

1- Why is Lua considered inferior?
Well, frankly, I'm not sure; this is not something I've heard all that often. I think that WillFa is right that it might suffer from the "just a toy" stigma due to being used as a lightweight language in games. In fact, its apparent simplicity can be misleading and make you think you can't actually do much with it. To be honest, I suspect that many people who say that Lua is inferior don't really know it very well. The main problem with Lua is its relatively small library base, but that is being fixed (LuaRocks is a good example of how, for instance).

2- Should I switch?
Well, I would say that you should never consider switching unless you've found a clear reason to. This is true in general. As they say: if it ain't broke, don't fix it. Don't change just for the sake of it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,100 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 17 Nov 2008 04:46 AM (UTC)
Message
Quote:

Why is Lua generally considered to be inferior to other scripting languages?


I don't consider it inferior, and many major commercial companies don't either, eg. Blizzard for World of Warcraft scripting.

The good thing about it is it is easy to learn, has a simple syntax, and is not overloaded with obscure things like the data name tells you what sort of data is stored in the variable.

It is also very fast, however very flexible. For example, useful concepts like tables within tables are easily expressed. In addition, it is easy to serialize tables (convert to strings) and convert back, as mentioned in the Lua section of this forum.

Also, MUSHclient has some extra facilities available to Lua scripters only (eg. iterating through a disk directory, getting data from web sites, compression, encryption, and a whole host of other utilities).

Quote:

Should I decide to switch over to another scripting language ...


No, I wouldn't. Lua suffers the least from memory leaks, as reported occur sometimes in other languages. It also works for people using Wine (Linux).

Also see this thread:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8306

In that post the head coder of Aardwolf says, amongst other things:


All of the game scripting in Aardwolf MUD is Lua based. Other than the rewrite itself, it has been the best single project we ever implemented.

Performance has been fantastic.

...

Bottom line, if you're wondering whether it is worth the work to convert to Lua, it absolutely is. Our builders love it and even mention side benefits like being able to put a "real" programming language on their resume.

...

It is fast, stable, and mainstream.

...

This stuff is exciting and I just can't rave enough about how great Lua has been for the MUD and the potential it opens up if you can find people creative enough to use it well.


Now that was written by someone who I had not even spoken to or heard from before that posting.

My advice is, don't convert from Lua, convert to it. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #4 on Mon 17 Nov 2008 06:08 AM (UTC)
Message
I'll agree with the people above. For MUSHclient, Lua is in 9 out of 10 cases the best way to go because scripts tend to have a narrow scope - you fiddle with mud input and output, for which MUSHclient offers the functionality. Additionally, there is little overhead and solid as a rock.

However, the 'little overhead' and speed arguments are not really a factor that weighs heavily in my opinion. My biggest script, which numbers almost 2,200 triggers, is written exclusively in Python, and I do not notice any slowdowns. Although I suppose the speed argument does make a differ when compared again VBScript or JScript.

In the end, it comes down on three issues:
1) What are you most familliar with.
2) What functionality you need.
3) Whether or not you are sharing your plugins.

In my case, my decisions are taken almost exclusively by 2) and 3), of which the latter weighs heaviest. My MudStatus plugin (I made a topic about it elsewhere two days ago) is the best example I can think of. Why Python over Lua?

Because Python has builtin support for fiddling with connections and raw sockets, whereas Lua does not. In Lua's case, I would have to make my users add the right stuff to the sandbox, and also send a luasockets library along to get it working. That's something many people may have trouble with, and alternatively I'm not too familliar with LuaSockets. In the case of Python, people will need to download all of Python, which is 30MB or so I think it was, relatively big. But nowadays, that is next to nothing, and telling someone 'Go install ActivePython' is very easy for them to follow, since it does not involve scripting and such. The latter is why I went with Python for the latter matter.

Mind you, that does mean the inherent sandbox of Lua is not used, and any security that might come from it is not either. But MUSHclient has a narrow userbase, and if anyone wanted to do anything malicious with a script, they'd quite likely just use VBScript since that's a 100% garantuee to work on all computers anyhow. ^^

I hope it helps you.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,643 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.