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
➜ Your favourite language!
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Nickpick
(24 posts) Bio
|
Date
| Mon 08 May 2006 09:29 AM (UTC) |
Message
| So, which language do you use and why?
I've been using VBScript, but I'm seriously thinking of switching to Python, simply because VB syntax gets on my nerves. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Mon 08 May 2006 10:10 AM (UTC) |
Message
| I use Lua because it's fast, powerful and very elegant as a language (both in practice and in principle). I also find it much easier to extend than most scripting languages. In general, I also like Lua because it has a much smaller footprint in disk and on memory than languages such as Python. And as a general nit-pick, I don't really like languages than use whitespace as a significant token (in Python, for instance, as a scoping indicator). |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #2 on Mon 08 May 2006 10:42 AM (UTC) |
Message
| Ah, Language Wars! This should be fun. :)
I too like Lua these days. It has a simple elegance, with a small formal definition, however can be extended pretty-much indefinitely by well-defined interfaces (that is, libraries).
Its string library has powerful functions, like its own regular expression parser, which my tests have shown is very fast.
You can handle runtime errors by wrapping any function into a "protected call" if you want.
Its table structure is very powerful at storing any sort of data keyed by any other sort of data. Tables can be nested.
Having said that, you can probably make a good case for any of the scripting languages, it is probably a case of "the right tool for the job".
Remember, Lua is freely available (no charge for it, no need to give an email address even). Unlike VBscript, it is cross-platform, and runs on any system that supports a C compiler, including Windows, Unix (Linux), and Macintosh. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nickpick
(24 posts) Bio
|
Date
| Reply #3 on Mon 08 May 2006 04:36 PM (UTC) |
Message
| Well if we are on about languages my top favourite is C++, but since it's not a scripting language, there's little good it can do with MushClient.
About Python, Lua and Co., I'm just looking for something different than VBScript, which simply has an ugly syntax. I liked Python optically, but if you say that Lua is good, I might well try it too. | Top |
|
Posted by
| Nickpick
(24 posts) Bio
|
Date
| Reply #4 on Mon 08 May 2006 04:44 PM (UTC) |
Message
| By the way, any good and preferably free Lua editors you know? MUSHClient editor sure is nice, but sometimes you just want more colour. | Top |
|
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Reply #5 on Mon 08 May 2006 05:38 PM (UTC) |
Message
| I recently switched to Lua myself. My old editor started crashing a lot (nothing to do with Lua) and in my search for a new one I found Crimson Editor, which has built in color syntax for lots of languages and it's well documented in the help on how to create your own syntax files for other languages or how modify current ones to meet your needs. I was really surprised that it came with a Lua syntax. It is free. |
Norbert
-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
| Top |
|
Posted by
| Nickpick
(24 posts) Bio
|
Date
| Reply #6 on Mon 08 May 2006 05:58 PM (UTC) |
Message
| Okey, one thing I need to admit already is that it is clearly faster than VBScript. | Top |
|
Posted by
| Rakon
USA (123 posts) Bio
|
Date
| Reply #7 on Mon 08 May 2006 05:59 PM (UTC) |
Message
| I personnally use python for all my scripts, triggers, and such, as well as a few plugins. But for portability of plugins, a few that I have written use VBscript. I really like the way python's syntaxs are, especially the whitespace character as a scoping indicator,(because I dislike searching for or forgetting that one 'end' or brace). I use Cedit(Crimson Editor) and I love the ability it has to color file syntax, all .py,pyw, and once configured, .pys. Yeeep Monty Python is the language for me. |
Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for. | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #8 on Mon 08 May 2006 09:16 PM (UTC) |
Message
| I personally use SciTE from here:
http://scintilla.sourceforge.net/SciTEDownload.html
for editing. It supports every language imaginable and you can edit the definition files (with some limitations) to have it color Mushclient commands for the language(s) you use the same as its own. Frankly, the only thing that bugs me is that no "Extended commands" option exists with a unique color for commands that are not part of the language itself. Say, blue for the language commands and orange or something for Mushclient. To do that required recompiling the Scintilla lexer dll itself, last I checked.
However, so long as you don't mind that limitation, it will color the syntax of damn near everything I have ever heard of. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #9 on Mon 08 May 2006 09:30 PM (UTC) |
Message
| Since we're talking about editors, I use vi (vim, actually) for most of my editing, even locally. It's one of the best editors, if not the best editor that I have used; once I got used to it of course. :-) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #10 on Mon 08 May 2006 09:41 PM (UTC) Amended on Wed 04 Jun 2008 09:17 PM (UTC) by Nick Gammon
|
Message
| Hmm, interesting. I had been using ScITE, however after trying Crimson Editor it also seems very nice.
Its home page:
http://www.crimsoneditor.com/
Quote:
Frankly, the only thing that bugs me is that no "Extended commands" option exists with a unique color for commands that are not part of the language itself.
I tried to add that to Crimson Editor with a good deal of success.
I edited the "key" file for Lua (in directory C:\Program Files\Crimson Editor\spec\lua.key) and added the following lines to the bottom. After reloading my script file all the MUSHclient script functions were coloured in orange.
[KEYWORDS3:GLOBAL]
#
# MUSHclient world library functions
#
Accelerator
AcceleratorList
Activate
... and so on ...
WorldPort
WriteLog
world
I entered the last one ("world") manually in case you did world.Note)
To generate the full list I did this in Lua:
for k, v in pairs (utils.functionlist ()) do
print (v)
end
After that you can add the MUSHclient extra Lua libraries (like utils) by doing this:
for k in pairs (utils) do
print ("utils", k)
end
(And then do the same thing for the "bit" library).
Of course, you could add the MUSHclient keywords to the key file for any language, not just Lua. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #11 on Mon 08 May 2006 09:50 PM (UTC) Amended on Tue 16 May 2006 11:29 PM (UTC) by Nick Gammon
|
Message
| There seemed to be a problem in Crimson Editor in detecting block comments, in that they were commented out in the lua.spc file. I suspect this is because the block comment delimiter was the same as the multi-line string delimiter. However this file contents *seemed* to work for me:
$CASESENSITIVE=YES
$DELIMITERS=(){}[]<>+-*/%="'~!@#&$^&|\?:;,.
$ESCAPECHAR=\
$QUOTATIONMARK1="
$QUOTATIONMARK2='
$LINECOMMENT=--
$SHADOWON=[[
$SHADOWOFF=]]
$BLOCKCOMMENTON=--[[
$BLOCKCOMMENTOFF=--]]
$PAIRS1=()
$PAIRS2=[]
$PAIRS3={}
$MULTILINESTRINGCONSTANT=YES
Strictly speaking, a multi-line comment is terminated by just "]]", not "--]]", however the Lua manual recommends using "--]]" because you can then simply include or exclude the entire multi-line block (assuming it is code) by simply adding an extra hyphen to the leading comment. Also, I think it looks more symmetrical.
To quote from their manual:
A common trick, when we want to comment out a piece of code, is to write the following:
--[[
print(10) -- no action (comment)
--]]
Now, if we add a single hyphen to the first line, the code is in again:
---[[
print(10) --> 10
--]]
In the first example, the -- in the last line is still inside the block comment. In the second example, the sequence ---[[ does not start a block comment; so, the print is outside comments. In this case, the last line becomes an independent comment, as it starts with --.
[EDIT]
Added a new line, found on another forum:
$MULTILINESTRINGCONSTANT=YES
This lets it recognise multi-line string costants, like this:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #12 on Mon 08 May 2006 09:56 PM (UTC) Amended on Mon 08 May 2006 10:00 PM (UTC) by Nick Gammon
|
Message
| However, back to languages, one of the really nice things about Lua is its ability to treat functions as "first class values" (as the manual says). What this means is that functions can be:
- assigned (eg. a = print)
- passed as parameters to other functions
- stored in tables
- constructed on-the-fly (eg. a function defined as an argument to another function)
- removed (eg. print = nil)
- have their behaviour changed - for example redefining print to also log (by saving the previous value as a local variable and then assigning a new one to it)
- have their environment changed - effectively this means that for a particular function call you can redefine its global address space, effectively "sandboxing" it
- call in protected mode - thus catching any errors inside the function and reporting them, rather than having the script terminate
This leads to some nice elegant programming, for example the sort function can take as an argument a function that specifies the "less than" test, so you can have custom sort orders.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nickpick
(24 posts) Bio
|
Date
| Reply #13 on Tue 09 May 2006 07:55 AM (UTC) |
Message
| Hmm.. Crimson does look nice.
On Lua tables: They really look like the arrays and I suppose they are arrays in a way. What I've been wondering about is whether it is possible to create 3D or 4D tables for Lua. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #14 on Tue 09 May 2006 08:23 AM (UTC) |
Message
| Sure. You can create n-dimensional tables in Lua. Since tables can be nested, and arrays are a special case of tables, you can have tables of tables of tables of tables of tables of tables of ... tables of tables of ... integers. :-)
For example,function Make2dMatrix(width)
local result = {}
for i = 1, width do
result[i] = {}
end
return result
end
matrix = Make2dMatrix(3)
matrix[1][1] = 1
matrix[1][2] = 2
matrix[1][3] = 3
matrix[2][1] = 4
matrix[2][2] = 5
matrix[2][3] = 6
matrix[3][1] = 7
matrix[3][2] = 8
matrix[3][3] = 9
for row = 1, 3 do
for col = 1, 3 do
io.write(matrix[row][col], " ")
end
io.write("\n")
end
This generates a 3x3 matrix, fills it up with some values, and prints them all out. The output is:$ lua tmp.lua
1 2 3
4 5 6
7 8 9
|
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | 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.
61,867 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top