Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: Python?
Home

[Freeciv-Dev] Re: Python?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Python?
From: "Brandon J. Van Every" <vanevery@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 Nov 2003 06:26:37 -0800

From: Raimar Falke [mailto:i-freeciv-lists@xxxxxxxxxxxxx]
>
> I assumed wrong when you said "migrating away". I didn't consider
> mixing two languages as in embedding. This is what you think about?!

Yes.  Make life easy on oneself.  Why would I try to rewrite Freeciv?
It is foolish; Freeciv already works.  Rather, do 1 teeny tiny new thing
in Python.  Like diplomatic AI.  (Well, it wouldn't end up teeny tiny,
but it could *start* that way.)

People keep doing teeny tiny new things.  People get experience in
Python.  People migrate to more ambitious things.  The whole process is
gradual.

> > Why must it be a complete rewrite?  That's why I suggested
> >"hodgepodge"
> > migration.  OO-ify things one at at time.  Most people
> >don't have time for complete rewrites.
>
> I'm really not sure that the result would be cleaner if you embedded
> language X in the C code and then rewrite the C code piece by piece.

Of course it would not be cleaner!  Nobody has time for that kind of
cleanlinesss, this is the real world.  It would be great if we all had
budgets to sit around and write huge chunks of perfect code from
scratch, but we don't.  Hence "hodgepodge OO."  You can still be "fairly
clean" with such an approach.  You just cannot be
perfect-from-scratch-rewrite clean.  It is an impossible standard to
live up to.

> While I haven't programmed a project of the size of freeciv with
> python I use it in the day to day business and also teach it. My two
> main concerns are: speed (last time I measured it was slower than java
> by a factor of about 10)

It is true that speed is still a weak spot in Python.  However, I'm sure
there are places in Freeciv where speed is not critical, or you've got
far bigger bottlenecks than Python to worry about.  A typical drill is
to barf stuff out in Python, then drop to C if you find out you *really*
need more performance.  People often think they need all this
performance, especially game developers, when usually they don't.  It's
best to wait until you find out what actually needs the performance.
What if your design is rendered obsolete by then?

> Consider code like this:
>
> class c:
>   def f(self,x):
>     # x has a to be certain type here
>     x["count"]=len(x)
>
>   def g(self,...):
>     ...
>     if some_rare_condition: # like test for leap year
>       self.f(a)
>
> Now thing what will happen if "a" isn't a mapping. When will you find
> this error?

Some people argue that only aggressive test suites can save you from
errors.  I am not sure.  I do write a lot of test suites for my own
code, but I am typically a lone wolf developer and in control of my
source pool.


Cheers,                     www.indiegamedesign.com
Brandon Van Every           Seattle, WA

Taking risk where others will not.



[Prev in Thread] Current Thread [Next in Thread]