Scripting Languages for Celestia

General discussion about Celestia that doesn't fit into other forums.

What language should Celestia use for scripting?

Perl
2
12%
Python
2
12%
Lua
8
47%
Tcl
0
No votes
JavaScript
3
18%
Something else
2
12%
 
Total votes: 17

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Scripting Languages for Celestia

Post #1by chris » 10.04.2003, 19:17

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

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #2by selden » 10.04.2003, 19:45

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.
Last edited by selden on 10.04.2003, 19:52, edited 1 time in total.
Selden

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #3by John Van Vliet » 10.04.2003, 19:48

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
Last edited by John Van Vliet on 10.04.2003, 19:53, edited 1 time in total.

billybob884
Posts: 986
Joined: 16.08.2002
With us: 22 years 3 months
Location: USA, East Coast

Post #4by billybob884 » 10.04.2003, 19:53

what exactly do you mean by runtime?
Mike M.

TacoTopia!

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #5by John Van Vliet » 10.04.2003, 19:57

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

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #6by chris » 10.04.2003, 19:58

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

Guest

Re: Scripting Languages for Celestia

Post #7by Guest » 10.04.2003, 21:18

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.

Rassilon
Posts: 1887
Joined: 29.01.2002
With us: 22 years 9 months
Location: Altair

Post #8by Rassilon » 10.04.2003, 21:33

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...
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #9by chris » 10.04.2003, 22:08

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

alexis
Posts: 55
Joined: 02.05.2002
With us: 22 years 6 months
Location: Stockholm, Sweden

Scripting

Post #10by alexis » 11.04.2003, 02:18

I've had some experience with Lua (v5), and it works great though it is still in beta.

/Alexis

Paul
Posts: 152
Joined: 13.02.2002
With us: 22 years 9 months
Location: Melbourne, Australia

Post #11by Paul » 11.04.2003, 02:33

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

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #12by chris » 11.04.2003, 03:05

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

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #13by chris » 11.04.2003, 18:33

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

helvick
Posts: 2
Joined: 13.04.2003
With us: 21 years 7 months
Location: Leixlip, Ireland

Post #14by helvick » 13.04.2003, 15:39

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

Guest

Post #15by Guest » 13.04.2003, 20:08

"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/


Return to “Celestia Users”