dynamic classes and duck typing

bearophile bearophileHUGS at lycos.com
Wed Dec 2 08:43:57 PST 2009


dsimcha:

>because Python's builtin arrays are too slow.<

Python lists are not badly implemented, it's the interpreter that's slow (*).
Python built-in arrays (lists) are dynamically typed, so they are less efficient but more flexible. NumPy arrays are the opposite. So as usual with data structures, they are a result of compromises and are chosen an optimized for your purposes.

(*) And the interpreter is slow because it's designed to be simple. Being simple it's possible for not very expert people too, people that do it in their free time, to hack and fix the Python C source code. This allows CPython to keep enough developers, so the language keeps improving. In the Python design there are many lessons like this that D developers have to learn still.


> A practical language should have enough complexity management tools to handle
> basically any type of complexity you throw at it, [...]

In the world there's space for smaller and simpler languages too, like Lua, designed for more limited purposes. Not every language must become an universal ball of mud like C++.


> If you can achieve this, your language will be good for almost anything.

I will not believe in the single True Language, sorry, just like there isn't a single perfect way to implement dynamic arrays.

Bye,
bearophile



More information about the Digitalmars-d mailing list