Alejandro Aguilar Sierra wrote:
> Are you sure it's enough stable? I can't run some not so old python
> programs because language version incompatibilities.
Python is stable in the sense that the basic programming language does not
change much. The libraries evolve however, and this can cause
incompatibilities.
This is also the situation with most variants of Scheme: The extra add-on
libraries change with every new release.
> I'm almost sure scheme is more stable than python as a language. Moreover
> there are alternatives besides guile, like siod, to adopt scheme as our
> scripting language. And people would not have to install an external
> library (siod is small, we could include it).
Scheme might be more stable than Python as a language in the sense that a
committee decides what is standard Scheme. However, the R5RS was released this
new (or maybe the year before), and no Scheme's I know of have been updated to
that yet, so in the near future, the language is expected to chance in
practice.
So in a sense, it's similar to C++: Every once in a while, the language is
changed, because a committee decides on a new language version.
The evolution of Python is similar, except that it's not a committee that
decides how the language should look, but rather the implementors. The basic
language does not change more often. The libraries change because better
libraries are developed. Of course, this can cause trouble for applications
that use the old libraries, but for a scripting language in LyX, I imagine the
use of external libraries that are likely to change would be limited.
(Regarding C++: In a way it's fortunate that C++ has become an ISO-standard.
That implies that the language is fixed for the next five years, because of the
ISO-standard regulations. This will hopefully give implementors enough time to
implement and optimize the language, before the next language version arrives.)
> Then I don't understand why you have not written at least a test program,
> so you can convince us, using the lyxserver *without* hacking lyx. ;)
That would not show anything of much interest... Almost every language can
interface with LyX through the LyX server...
Instead, I tried to embed the Python 1.5 interpreter in LyX-v1pre4 just now.
It is as easy as adding four lines to main.C: #include "Python.h",
Py_Initialize() at the start of main() and Py_Exit() at the end of main().
Also, I added a line that executed a basic Python statement to see if it
worked.
Then I added the appropriate include- and link-flags to the Makefile and
recompiled. And it worked the first time without any problems. If you want to
try yourself, first get the "Demo/embed" example in the Python documentation
working. Then, simply port the relevant lines into main.C in LyX.
The stripped executable grew with 300k, because the libpython is statically
linked (on my system, there were no dynamic link library version of Python.)
With two more lines, I had a complete and running Python interpreter inside
LyX, and could practically do everything you can do with Python right there. I
got a game of Tetris running in the terminal from which LyX was started. Of
course these things are just games, but they demonstrate that the technology
works.
With a few more lines, I could interface Python with the LyX dispatcher, and
then the scripting-language would practically be done. With a patch smaller
than 50 lines, we would have the basic scripting language implemented, ready
for doing things like a primitive graphic tutorial. If it should be a little
more advanced with small graphics and buttons in the dialogs, we would need a
few more functions in LyX, but nothing that couldn't be done in a day.
There are a few potential serious problems though: The linking step required
the use of a bunch of extra libraries such as dl and pthreads that were linked
dynamically. These libraries depend on the specific configuration of the
Python installation, and will thus vary from system to system. I don't know if
this is something "configure" can handle, or not. If not, this is a serious
practical problem, because it makes the configuration of LyX a lot harder: You
have to know your Python installation in detail in order to link LyX. Of
course, this is not acceptable, but before we dismiss Python, we should
investigate whether configure or some other means can determine this stuff
automatically.
If we used a small Scheme, such as siod, we would avoid this kind of problem,
but the main reservation I have with Scheme is the syntax of the language,
which I fear is not easy to learn for novice users. I would like the syntax of
the scripting language to be as simple as possible, and this is the primary
reason I like Python for a scripting language in LyX.
I think it's very important that the learning curve for a scripting language is
really low so that everybody can get started with it. Of course, the language
should be capable enough to solve the travelling salesman problem, and it
should of course be as expressive as possible (all considered languages fits
this), but the most important thing is a simple syntax for simple stuff.
The target audience for the scripting language in LyX is NOT programmers: It's
LyX power users that want to create shortcuts for common operations, and maybe
a few super power users will implement the favorite missing feature (such as
mail merge) they need.
In order words it's for the most part non-programmers. So using a
polish-notation syntax language such as a Lisp variant will scare people away:
They would never accept that they have to write (+ (2 3)) instead of 2+3. Only
programmers are interested in this, and see the benefit of doing this.
(I realize that Emacs is an example that demonstrates that people are willing
to write lisp-syntax, and lots of it, but I think this is because the primary
target users of Emacs are programmers.)
In other words, I fear that if we chose a scripting language that does not have
some kind of "natural" syntax, we would only get the current LyX developers and
a handful of other people to use it. If we got a really easy-to-use scripting
language, I think we could have hundreds of people writing LyX scripting code
and make it really explode. (Maybe I'm mistaken -- we could put up a poll on
the LyX web-site...)
But, I would be interested in hearing about experiments with embedding siod or
another Scheme implementation into LyX, in the lack of a better alternative.
The more information we have about this issue, the better a decision we will
make.
Also, if someone know of an entirely different candidate scripting language, I
would be very interested to hear about that. Maybe somebody did an embeddable
Basic or Comal?
Is the syntax of tcl easy to understand? (I never wrote a TCL program, maybe
that's another language worth learning...)
Greets,
Asger