Embedded scripting languages

So, it might be worth bearing this in mind if considering Python as an
embedded interpreter. Andrew suggests some type of dual mode so that
the user can choose either between Python or something closer like

It’s been a while, but Marcus and I were just discussing this. I’ve
always assumed that Avogadro would need two modes for embedded
scripting. The catch is that we don’t yet have either.

You want to have a Python mode, because you want to allow plugins to
be written in Python. So some debugging may need an embedded Python
interpreter. And you may want functions not exposed in a simple
scripting language. (For example, if you want to access some other
Python library, or make system calls… etc.)

But you also want some “easy” mode, so “rotate x 45” means something
like “rotate 45 degrees around the x axis”

IMHO, we want something like the Jmol scripting language:

http://chemapps.stolaf.edu/jmol/docs/

There are a number of nice advantages:

  1. There are already people who know Jmol scripting. (It’s also like
    the old Chime plugin.)

  2. It’s a reasonable syntax:
    rotate X 10
    rotateSelected X 10
    background [255,0,255]
    minimize

  3. We can work with Jmol to define a reasonable open standard and
    share scripts and documentation.

Cheers,
-Geoff

Geoffrey Hutchison wrote:

So, it might be worth bearing this in mind if considering Python as an
embedded interpreter. Andrew suggests some type of dual mode so that
the user can choose either between Python or something closer like

It’s been a while, but Marcus and I were just discussing this. I’ve
always assumed that Avogadro would need two modes for embedded
scripting. The catch is that we don’t yet have either.

You want to have a Python mode, because you want to allow plugins to
be written in Python. So some debugging may need an embedded Python
interpreter. And you may want functions not exposed in a simple
scripting language. (For example, if you want to access some other
Python library, or make system calls… etc.)

But you also want some “easy” mode, so “rotate x 45” means something
like “rotate 45 degrees around the x axis”

IMHO, we want something like the Jmol scripting language:

http://chemapps.stolaf.edu/jmol/docs/

There are a number of nice advantages:

  1. There are already people who know Jmol scripting. (It’s also like
    the old Chime plugin.)

  2. It’s a reasonable syntax:
    rotate X 10
    rotateSelected X 10
    background [255,0,255]
    minimize

  3. We can work with Jmol to define a reasonable open standard and
    share scripts and documentation.

I’d like to put in my vote for using ipython
(http://ipython.scipy.org/moin/About).

It addresses lots of the issues which stop people otherwise using python
as an interactive shell in that:

  • you can type standard shell commands, so that, e.g. “ls”, “pwd” and
    "cd" do what you think they should.
  • it’s got auto-parenthethes so that you can type " move 1 2 3 " instead
    of " move(1,2,3) ", or " ,foo one two three " instead of "
    foo(“one”,“two”,“three”) "
  • it has auto-completion.
  • it remembers commands so that you can use the arrow keys to toggle
    back up through commands.

If you need to simplify the command structure, then you can always write
a wrapper layer (ala pybel) to provide commands simple enough to
remember and type at the command line - and if desired, these could be
kept very similar to the Jmol language.

It has the additional advantage that it keeps everything in the same
language, and as Python is poised to take over the world ;-), I think
this has to be a good thing.

Just my tuppence-worth - and for those in the US that’s nearly 4
cent’s-worth, so please listen up :wink:

Best wishes,

Jens

Jens Thomas, email: j.m.h.thomas@dl.ac.uk
STFC Daresbury Lab, tel: +44-1925-603849
Warrington, fax: +44-1925-603634
WA4 4AD, UK. http: http://www.cse.scitech.ac.uk