[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Scripting languages, dumb(?) question
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Scripting languages, dumb(?) question

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


Posted by Scypio   Poland  (50 posts)  [Biography] bio
Date Fri 26 Nov 2004 07:28 PM (UTC)
Message
Ok, so now that MC provides support for yet another scripting language, I am curious if there are any serious differences between various scripting languages capabilities, i.e. if there are things that would be easy to do in one language and impossible/extremely hard to do in another language? (In another words, is the difference between languages not only 'how you do it' but also 'what you can do'?)
If yes, what are those things? Are the differences only important for advanced scripting? Or for things that someone with quite a basic knowledge of scripting could/would do?
Oh, and in my question, I'm not asking about MC-supported scripting languages in general - I am referring only to MU* functionalities.
[Go to top] top

Posted by Nick Gammon   Australia  (21,405 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 26 Nov 2004 08:28 PM (UTC)
Message
All of the scripting languages basically support the same MUSHclient functionality, so it is really a question of what language you prefer to work with. Internally, except Lua, they all use the COM interface (Component Object Model) so they effectively have access to the same capabilities.

However about 3 functions only seem to work as documented in VBscript: GetAlias, GetTrigger and GetTimer. This is because they return data "by reference" which the other languages do not seem to support. That means, it modifies the arguments to the function.

In the Lua interface, those 3 functions can still be used because they return their data as multiple return values.

For the other languages, MUSHclient had added extra functions (like GetAliasInfo, GetTriggerInfo, GetTimerInfo) to return the same data in a different way.

In the Lua interface a handful of functions (like GetVariableList, GetStyeInfo, GetLineInfo) have been enhanced to return more information, however this information is still available through the other languages in a slightly different way.

So really the answer is "it makes no difference", just choose the language you feel most comfortable with.

Remember, if you are planning to distribute (or even just post on a web site) code, people are most like to have access to:


  • VBscript (comes with Internet Explorer)

  • JScript (ditto)

  • Lua (comes with MUSHclient version 3.52 onwards)


If you script in Perl, Python, PHP or whatever, then your target audience may not have those installed, and may not want to install them.

Also, if you are planning to run on Linux under Wine, then Lua seems to be the most reliable, as it does not use the COM interface at all, which seems a bit flaky under Wine.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #2 on Fri 26 Nov 2004 09:41 PM (UTC)
Message
This should answer a few things"

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

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #3 on Sat 27 Nov 2004 12:13 AM (UTC)
Message
Well.. That thread goes off on a tangent to some extent and really doesn't cover the question too well. In general, the more universal that language and widely used, the odds are it will have more features. I am not sure about Lua, but if it is anything even close to Python, then the limits are only the libraries you have installed with it. Perl is close to these, but can't be extended as easilly as Python or Lua. Java (meaning in this case MS Java) is a bastardized version and intentionally hamstrung as a languange, missing even a few things VBScript has in it. VBScipt is a major downgrade from true VB and is missing many things that might be considered 'basic' functions. Conversion to and from DATE types being a good example of something it just won't do. Some stuff missing from VB, like the extended date/time functions, is in Java. PHP, if Nick ever gets it working, is entirely internet based, so probably has a slew of things missing from it.

All in all, the best 'languages' are probably Lua and Python, because they are *real* languages that just happen to be designed to also perform scripting. The rest of them are either, like PHP, never meant to exist outside a web page, or are severely labotimized versions of existing languages. They are what they are because even MS (with their questionable track record otherwise) agreed that having a script be allowed to do something dangerous was probably a bad idea, so anything that even looked like it wasn't 100% necessary our potentially could be misused got deleted from them. Unfortunately, for many of us this mean they can't be used to achieve some of the most interesting ideas. VBScript and JavaScript simply don't have the versitility or functionality to manage it. However, for most scripting they are all pretty good, even though they each suffer from a few unique quirks.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #4 on Sat 27 Nov 2004 12:41 AM (UTC)
Message
Quote:
Perl is close to these, but can't be extended as easilly as Python or Lua.
Why do you say that?
Quote:
Java (meaning in this case MS Java) is a bastardized version and intentionally hamstrung as a languange, missing even a few things VBScript has in it.
You mean, Javascript. MS Java itself isn't reduced in features from normal Java - the problem is that they added their own things that aren't in the standard at all, thus making their version of Java useless on other systems. This defeats the whole purpose of Java in the first place, which is to be as portable as possible.
Quote:
The rest of them are either, like PHP, never meant to exist outside a web page, or are severely labotimized versions of existing languages.
PHP is a "real" language. It happens to be mainly used for webpages, but it can also be used to implement any old script just as well as Perl and the others..

Quote:
They are what they are because even MS (with their questionable track record otherwise) agreed that having a script be allowed to do something dangerous was probably a bad idea, so anything that even looked like it wasn't 100% necessary our potentially could be misused got deleted from them.
Err, well, not really - they're not meant to be "real" programming languages, and they're not meant to do anything but simple scripts. MS bashing is fine, but only when they actually did something wrong - there are plenty of opportunities for that. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Scypio   Poland  (50 posts)  [Biography] bio
Date Reply #5 on Sat 27 Nov 2004 11:16 AM (UTC)
Message
So, can you give any more examples of the features missing from one languages and existing in others? Or things easily feasible in one language and hard/impossible in others?
Because so far, what I understood from this discussion is that: VBS lacks extended date/time functions, that JS has; Python can be extended with libraries (examples, please?), so might be Lua, and Perl too, but not that easily(why?).
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #6 on Sat 27 Nov 2004 12:32 PM (UTC)
Message
VBscript is pretty bare bones, so is JScript (I have never programmed in it though), Python/PHP has libraries to do almost anything already, Perl I don't know, and Lua seems like VBscript with a few extra abilities (and then whatever is in the libraries).

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Somegirl   (33 posts)  [Biography] bio
Date Reply #7 on Sat 27 Nov 2004 03:12 PM (UTC)
Message
Lists and dictionaries in Python are two features that made me switch from VBscript. Also, instead of writing several plugins in Python, you can create a library with modules for everything you want to do.
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #8 on Sat 27 Nov 2004 05:53 PM (UTC)
Message
Quote:
MS bashing is fine, but only when they actually did something wrong


Ah, you mean like implimenting 'safe' scripting, but still allowing those scripts to use and execute unsafe ActiveX components within the browser? ;)

Anyway, did't know that PHP was that expandable. And yeah, I meant JScript in my comment, not Java. Though the tendency of MS to take standards, hack out stuff they don't like, add back in proprietary junk, then insist that their 'new' standard is somehow better definitely one reason to avoid the full MS Java as well. Sorry for getting some facts wrong... Was speaking from what I had seen things used for and you simply don't hear of PHP in any context other than the web for the most part, so I assumed it had similar limitations to other web-centric languages.
[Go to top] top

Posted by Nick Gammon   Australia  (21,405 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Sat 27 Nov 2004 06:59 PM (UTC)
Message
I haven't extensively programmed in Python, Perl, or TCL (no time!), however having used VBscript a fair bit, and JScript less, I can comment to an extent. :)

The limitation I see with VBscript is its array handling - I think Shadowfyr has commented a while back that it is a pain to redimension arrays, and even just use them.

The nice thing about Lua, which I have been pushing recently, is its table management. Effectively its tables are like dictionaries and lists.

What that means is, that if you use numeric keys, generally starting at 1, then it is like a list, however one that can be expanded or contracted indefinitely.

Just to bang on about Lua for a bit more, I'll give an example. I'll create an empty table, insert 3 items, add a new one *to the middle*, and then delete the first one. After that, I'll sort it.


-- helper function to print the table
function printit (x)
  print ()  -- blank line first
  table.foreach (x, print)  -- print keys and values
end

t = {}
table.insert (t, "Hello")
table.insert (t, "World")
table.insert (t, "Foo")

printit (t)

-- insert new item at position 2
table.insert (t, 2, "New")

printit (t)

-- remove item at position 1
table.remove (t, 1)

printit (t)

-- sort ascending
table.sort (t)

printit (t)

-- output:

1 Hello
2 World
3 Foo

1 Hello
2 New
3 World
4 Foo

1 New
2 World
3 Foo

1 Foo
2 New
3 World


This is pretty straightforward, yes? You can insert, delete and sort. Lua tables let you implement stacks, queues and double queues, simply by inserting or removing at each and as required.

However the other thing you can use them for is dictionaries or "maps". In this case you simply index directly to each entry:


t = {}

t ['name'] = "nick"
t ['hp'] = 22

printit (t)

print ("his name is", t.name)

-- output:

hp 22
name nick
his name is nick


Now the table is being used as a dictionary, where you can insert any item by key, and retrieve it the same way (as in the last line, printing t.name).

Now in fact Lua is designed to be very small and compact, with the real power being the ability to extend it with extra libraries. The PCRE library, which I incorporated into MUSHclient, is an example of that. Others are available on the web, such as a socket library, that - in about 4 lines of code once you install it - let you pull in an entire web page from another site using the HTTP protocol.

One other really nice thing is the ability to have optional arguments to function calls, and return multiple results.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


6,272 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]