Page 1 of 1

Scripting Languages for Celestia

Posted: 10.04.2003, 19:17
by chris
Celestia needs a replacement for the very rudimentary scripting that it currently has. I started out writing my own scripting language, but have decided that I'd be better off using an existing one and spending my time on other Celestia development.

Here's the list of possilbities that Christophe, Fridger, and I have come up with:

Perl
Advantages: familiar, powerful
Disadvantages: big runtime

Python (http://www.python.org/)
Advantages: familiar (though not as much as perl), powerful, probably cleaner than perl
Disadvantages: big runtime

Lua (http://www.lua.org/)
Advantages: tiny, extensible
Disadvantages: small user base

Tcl (http://www.tcl.tk/)
Advantages: tiny, many users, extensible
Disadvantages: wacky syntax

JavaScript
Advantages: huge user base
Disadvantages: fairly large runtime (500k)

As far as size Python and Perl are the largest, and are probably overkill for Celestia. JavaScript is in the middle, and Tcl and Lua are both tiny. I'm quite enamored of Lua at the moment--it's small, clean, easily extensible, but lack's Tcl's aggravating (IMO) syntax. Mozilla's SpiderMonkey implementation of JavaScript looks promising--I just wish it wasn't so big.

--Chris

Posted: 10.04.2003, 19:45
by selden
Have you looked at REXX? The varant named Regina is available for most platforms. ( I used to use AREXX when I had an Amiga, but that was long ago :( )

FWIW, quick skim of the Python web site seemed to suggest that there's quite a bit of infighting going on about the direction that the language should be headed.

Whatever language is chosen, I'd be concerned about it getting modified out from under you, making all the (not yet) existing scripts unusable.

Right now there are few enough scripts that it probably doesn't matter which language is chosen in terms of compatibility.

I'd also vote for a small, simple language, not a large, complex one.

re

Posted: 10.04.2003, 19:48
by John Van Vliet
How about PHP then it would be cross platform , and some what easy to use
one other thing a lot of people all ready know some ? php/html , but perl/pear people are perl and tcl people are tcl people and python peoplelike python

very hard choice witch one

Posted: 10.04.2003, 19:53
by billybob884
what exactly do you mean by runtime?

re

Posted: 10.04.2003, 19:57
by John Van Vliet
hi billybob i think chris means that you have to allready have java on your sys 1/2 meg is about size that java takes up on your systom

Posted: 10.04.2003, 19:58
by chris
Some code samples:

Tcl implementation of factorial:

Code: Select all

proc fac {x} {
    if {$x <= 1} {
        return 1
    } else {
        return [expr {$x * [fac [expr {$x-1}]]}]
    }
}


Lua implementation:

Code: Select all

-- calculate the factorial function
fac = function(x)
    if (x == 0) then
        return 1
    else
        return x * fac(x - 1)
    end
end


REXX implementatioin:

Code: Select all

factorial: /* calculate the factorial of the argument */
    procedure
    parse arg p
    if p<2 then return 1
    else return factorial(p-1) * p


--Chris

Re: Scripting Languages for Celestia

Posted: 10.04.2003, 21:18
by Guest
chris wrote:Celestia needs a replacement for the very rudimentary scripting that it currently has. I started out writing my own scripting language, but have decided that I'd be better off using an existing one and spending my time on other Celestia development.

Here's the list of possilbities that Christophe, Fridger, and I have come up with:

Perl
Advantages: familiar, powerful
Disadvantages: big runtime

Python (http://www.python.org/)
Advantages: familiar (though not as much as perl), powerful, probably cleaner than perl
Disadvantages: big runtime

Lua (http://www.lua.org/)
Advantages: tiny, extensible
Disadvantages: small user base

Tcl (http://www.tcl.tk/)
Advantages: tiny, many users, extensible
Disadvantages: wacky syntax

JavaScript
Advantages: huge user base
Disadvantages: fairly large runtime (500k)

As far as size Python and Perl are the largest, and are probably overkill for Celestia. JavaScript is in the middle, and Tcl and Lua are both tiny. I'm quite enamored of Lua at the moment--it's small, clean, easily extensible, but lack's Tcl's aggravating (IMO) syntax. Mozilla's SpiderMonkey implementation of JavaScript looks promising--I just wish it wasn't so big.

--Chris


Hi all,

"Lua" reminds me of a poisonous Brazilian snake;-); yes I spent about
half a year in Brazil, a long time ago (dancing Samba from morning to
night, of course)...

Back to more serious matters:

Perl, Python are great, but definitely overkills...

And moreover: let me do a poll among this illustrous group of 600 "Celestians":
who of you Windows addicts really "speaks" Perl?;-)

Of course, I know exactly who is speaking Perl here, and counting the
'perls' takes less than the five fingers of my hand.

Since Perl is still simpler and better known than Javascript among
non-professionals at least, skip Javascript, too...

Remains Lua/lua;-) and Tcl/Tk, both being small, well embeddable and
extensible.

The glorious days of Tcl/Tk also seem to be over, so let's take
Lua/lua for a change...


Bye Fridger

PS: from now on all my mails will be anonymous, since the write of this mailbox-upgrade code has decided to make the login incompatible with Netscape 4.x.

Posted: 10.04.2003, 21:33
by Rassilon
Hey Fridger you speak Perl :)

I think you should stick with the current setup or use the XML type scripting dtessman was working on for open universe...

Posted: 10.04.2003, 22:08
by chris
Rassilon wrote:Hey Fridger you speak Perl :)

I think you should stick with the current setup or use the XML type scripting dtessman was working on for open universe...


The current system is much too limited. There are no variables or flow control constructs . . . Celestia's gotten complex enough that real language features would be useful for creating tutorials, augmenting the UI, extensions, and other things. dtessman's XML stuff is for specifying data files; it would replace .ssc files, not scripts.

I will leave the current scripting system in Celestia, however there won't be any new commands added to it.

--Chris

Scripting

Posted: 11.04.2003, 02:18
by alexis
I've had some experience with Lua (v5), and it works great though it is still in beta.

/Alexis

Posted: 11.04.2003, 02:33
by Paul
If I could vote against one, I would vote against Tcl/Tk, as A) I've used it before and I hated it; and B) it's a little too old IMO.

I like the idea of choosing a language whose interpreter is smallest and has the best performance. Let's face it, in the years to come Celestia enthusiasts are going to write some hideously complicated scripts :wink: , and we'll want to have chosen the intepreter which can best handle them.

Also, it probably better to choose a newer language, as that language's development typically benefits in hindsight from the problems encountered with other languages, and so is more well-designed and implemented.

Given these considerations, I would choose Lua.

Cheers,
Paul

Posted: 11.04.2003, 03:05
by chris
Paul wrote:If I could vote against one, I would vote against Tcl/Tk, as A) I've used it before and I hated it; and B) it's a little too old IMO.
I agree completely . . . I listed Tcl as a choice, but someone would have to come with an incredibly compelling reason for me to overlook its syntax and actually use it. The expression syntax is just hideous . . . I know it's just syntax, but when doing a lot of math (which at least Celestia scripts will certainly do), concise notation is very important. One of the nice things about Lua is that you overload the arithmetic operators to handle new types that you create with C extensions. So vectors, matrices, quaternions, etc. can be manipulated very naturally . . .

Paul wrote:I like the idea of choosing a language whose interpreter is smallest and has the best performance. Let's face it, in the years to come Celestia enthusiasts are going to write some hideously complicated scripts :wink: , and we'll want to have chosen the intepreter which can best handle them.
I don't think any of the interpreters would have trouble with large programs. Interpreter size doesn't necessarily correlate with performance--in fact, I suspect that Perl or Python might execute programs the fastest, though that's nothing more than intuition.

Paul wrote:Also, it probably better to choose a newer language, as that language's development typically benefits in hindsight from the problems encountered with other languages, and so is more well-designed and implemented.
Here I agree completely . . . Notice that no other language has emulated Tcl's syntax :)

Paul wrote:Given these considerations, I would choose Lua.

So far, that's my conclusion as well . . . Are there any other small, embeddable interpreters out there?

--Chris

Posted: 11.04.2003, 18:33
by chris
I've been experimenting with integrating Lua into Celestia. Here's very small taste of the likely future of scripting in Celestia--the first Lua script to run in Celestia:

Code: Select all

celestia:flash("Hello")
celestia:show("boundaries", "constellations", "orbits")


This is a lot of fun :)

--Chris

Posted: 13.04.2003, 15:39
by helvick
Chris,

I'd never heard of Lua until you posted this but having taken a quick look at it it really does seem to be the best choice by far. As a committed Perl fanatic I'd love to see Perl scripting capability in Celestia but it would be overkill from a size point of view and to be fair to Lua it crams a very impressive amount of functionality into a very small package.

As someone who really wants to do some intricate scripting with Celestia I've been hoping for major developments in this area for some time. If it requires that I learn (quite) a bit about Lua in the process then I'm very happy to do that, as I'm sure are many others. :)

JoeM

Posted: 13.04.2003, 20:08
by Guest
"The current version is Lua 5.0, released on 11 Apr 2003"

"Lua means moon in Portuguese and is pronounced LOO-ah. "

http://www.lua.org/