Article of interest: Python pros/cons for the enterprise

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Feb 23 04:57:01 EST 2008


On Fri, 22 Feb 2008 10:00:16 -0800, Nicola Musatti wrote:

> On Feb 22, 5:13 pm, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
>
>> But somehow you still manage memory by writing in a style that favors
>> value types.
> 
> Certainly, but this is a natural C++ programming style, at least for
> those that aren't too deeply rooted in their C heritage.

Or are used to think of OOP as a graph of objects that are communicating
with each other.  In the value type style you are "talking" to copies of
objects all the time which I find a bit confusing because *I* have to keep
track of which maybe not so identical twin brother of an object I'm
talking at each point.

Also it seems odd to me to copy large collections around instead of
passing references.  Your `izip()` creates a quite small `map` -- what
about big ones.  With mutable objects!?

I like C and until I discovered Python, I liked Java.  Then I looked at
C++ and find it really ugly and confusing.  Even Haskell looks somewhat
easier to me.  Someone mentioned D -- that's a good step between C++ and
Java IMHO.  Garbage collection plus an easy way to declare "scoped"
variables that are destroyed when the names goes out of scope. So one can
leave memory management most of the time to the runtime but use RAII for
files, locks and other resources.  The `main()` of your C++ example looks
like this in D:

void main()
{
    auto m1 = 3;
    auto m2 = 4;
    scope a = new int[0];
    scope m = izip(m1, m2);
    foreach (int first, int second; m) {
        if (h(first, second).frob == 7) {
            a ~= [f(first) + g(second)];
        }
    }
    foreach (int i; a) writef("%d\n", i);
}


Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list