Re: [dev] Conversation with Anselm R. Garbe of suckless.org

From: Amit Uttamchandani <atu13439_AT_csun.edu>
Date: Tue, 15 Sep 2009 11:21:28 -0700

On Tue, Sep 15, 2009 at 02:35:46AM +0200, Uriel wrote:

[snip]

> >
> > Some examples:
> >
> >  1. I designed a software to automate testing of the boxes that we
> >  build. The main language used is Python (I guess it's hard to avoid OO
> >  when using python). Basically the design is such that I have a test
> >  case class that is used when instantiating different test cases
> >  (attributes include: name, status, tester, etc.). How would you
> >  approach this in a non-OO way?
>
> It is perfectly possible to write Python code without doing OO, as
> long as you stay away from the awful 'frameworks' out there that force
> you all kinds of insane crap like mixins down your throat.
>
> For example I just wrote a tracker for App Engine in python without
> even using a single class: http://repo.cat-v.org/atrack/ Other people
> had writen trackers before, but they used OO and they were *much*
> bigger, much more complicated, much slower, and much harder to hack
> on.
>
> Note that using classes in python is OK, as long as you just use them
> as structs, and *never* *ever* *under any circumstance* use
> inheritance. And there is the main problem because some APIs pretty
> much force you to use inheritance, but usually that can be isolated
> with some care, but it is a big pain.
>
> (Also 'objects' in python act much as dictionaries if you ignore the
> inheritance stuff, so dictionaries and classes can be used somewhat
> interchangeably).
>

I've been looking at the source of atrack. It is good reference. Thanks
for sharing.

>
> >
> >  2. A colleague of mine needed to design a packet generation engines for
> >  our box. He used OO concepts in CC by using techniques such as VTABLE,
> >  defines for methods, classes, etc:
> >
> >  /**
> >  * Macros for declaring classes
> >  */
> >  #define CLASS(CX, SX)\
> >     typedef struct CX *CX;\
> >     struct CX {struct SX super;
> >  #define IMPLEMENTS(IX) struct IX *IX
> >  #define VTABLE(CX, SX) };\
> >     extern struct CX##Class __##CX;\
> >     typedef struct CX##Class *CX##Class;\
> >     struct CX##Class {struct SX##Class super;
> >   #define METHODS };
> >   #define END_CLASS
> >
> >  So then, he can instantiate multiple different engines depending on
> >  processor load, etc.
>
> Your friend should beaten up semi-unconscious with metal bars, thrown
> into a big hole in the ground, and then have the hole filed with
> liquid feces until he drowns.
>

I'll think about it :).

> Peace
>
> uriel
>
Received on Tue Sep 15 2009 - 18:21:28 UTC

This archive was generated by hypermail 2.2.0 : Tue Sep 15 2009 - 18:24:02 UTC