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: "Brandon J. Van Every" <vanevery@xxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Python?
From: Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sat, 22 Nov 2003 15:44:18 +0100

On Sat, Nov 22, 2003 at 06:26:37AM -0800, Brandon J. Van Every wrote:
> 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.

Hmmm. I have no experience here. Since the existing C code works more
or less ok the other language will be used for new code/new features?!

> > > 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!

Cleanness and understandability are important for
maintainability. Freeciv is about 7 years old. I do expect to live it
a lot of future years. Maintainability is important for this.

Freeciv is also today quite complex. I have no idea how it will be if
you have to jump between two languages if you want to trace a function
call.

> 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.

I had to experience this myself. Let me say that the current Freeciv
style is _not_ what you see in the real (commercial) world. Which one
is better is hard to say. A mix of both probably.

> > 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?

I agree with you. For a complete rewrite speed would be a problem for
embedding it isn't.

> > 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.

And do they catch all/all most all/most errors?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "How about the new language C&? No, that's not 'c ampersand', 'c reference', 
  'reference to c' or 'c and'. It's pronounced 'campersand', to confuse the 
  hell out of people who are unfamiliar with it, and it will, of course, 
  have no pointers."
    -- Xazziri in comp.lang.c++ about C#


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