[crossfire] (Python)

Nicolas Weeger nicolas.weeger at laposte.net
Tue Oct 11 04:36:58 CDT 2005


>
        But all this doesn't really answer the question - when
     should something be in 
>
      python, and when should it be coded in C?
     
True. As I see it, Python is used when you want to make it
easy to customize things (no need to recompile) or "quick" (as
in quick to implement) things, C else.
Thus GPS is a good example of thing that can be done either in
C or Python. It's quite simple, isn't performance critical,
and can easily be extended (use "gps coins" to run, have a
delay before displaying result, ...). But doing it in Python
means you don't need to create a new item type for it, the
Java editor will handle it out of the box easily, and such.

Arguably the mail scripts could be put in server core too,
since they add things.

Also, Python is more easy for map designers, to extend
gameplay. It's easier to distribute map + Python script than
map + server patch, no need to recompile, and so on. Remember
compilation can be a pain on some platforms :)
And you can put the map & script on a running server, et
voila, it works without any restart required - nice for uptime.

>
        I haven't looked at the python code really closely, but
     what I gather is that 
>
      a badly written python script is as dangerous for the server
     as badly written C 
>
      code (eg, the script could do things to objects it
     shouldn't, etc).

Yep. A mere "sys.exit()" in the script just exits the whole
server - whoops. Also you can (for now, maybe it'll change
with plugin rewrite) overwrite any value in the objects, trash
things around, whatever you want :)

>
        Especially true if python is a requirement - in that case,
     the case that 'this 
>
      isn't really required so is in python' goes away, as python
     would be required, 
>
      then everything could be done in python.
     
Well, I see a few solutions:
* make Python mandatory. Maybe not the best solution, Python
is not installed on some platforms (Windows), and we don't
really want to force people to install it, I think. Especially
since Python comes with a zillion libraries, security
considerations, some PATH issues, and such - and let's not
start on version dependencies :)
* have many small plugins, in C. If we find a simple way to
build plugins, it would make it easy to write small specific
plugins (gps, item transformation) that could be built and
ran, but still not go into server "core".

I think we then run into the server's design idea: do we want
a "big" server, with every function builtin? A modular server
with many plugins? A server with many Python scripts, thus
making not having Python a major hindrance (not sure of the
spelling on that one)?

Maybe we can take a median way, actually. For now, concentrate
on the server core, redo map protocol, things like that. Let
new features / functions be handled by Python / plugins. Then
when we'll decide the core is good, put some of those features
in core.

Ryo

Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)




    


More information about the crossfire mailing list