dynamic classes and duck typing
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Dec 1 10:58:23 PST 2009
Leandro Lucarella wrote:
> retard, el 1 de diciembre a las 11:42 me escribiste:
>> Tue, 01 Dec 2009 03:13:28 -0800, Walter Bright wrote:
>>
>>> retard wrote:
>>>> Overall these simplifications don't remove any crucial high level
>>>> language features, in fact they make the code simpler and shorter. For
>>>> instance there isn't high level code that can only be written with
>>>> 8-bit byte primitives, static methods or closures, but not with 32-bit
>>>> generic ints, singletons, and generic higher order functions. The only
>>>> thing you lose is some type safety and efficiency.
>>> I'm no expert on Python, but there are some things one gives up with it:
>>>
>>> 1. the ability to do functional style programming. The lack of
>>> immutability makes for very hard multithreaded programming.
>> Even if the language doesn't enforce immutability it's indeed possible to
>> use immutable data types in a language without pure/const/final
>> attributes.
>
> And BTW, Python *have* some built-in immutable types (strings, tuples,
> integers, floats, frozensets, and I don't remember if there is anything
> else). Python uses convention over hard-discipline (no public/private for
> example), so you can make your own immutable types, just don't add
> mutating methods and don't mess with. I agree it's arguable, but people
> actually use this conventions (they are all consenting adults :), so
> things works.
>
> I can only speak from experience, and my bug count in Python is extremely
> low, even when doing MT (the Queue module provides a very easy way to pass
> messages from one thread to another).
But wait, my understanding is that threading in Python is a complete
shame: one global lock. Is that correct? FWIW, that's such a bad design
that _nobosy_ I know every brought it up except in jest.
> I agree that, when you don't care much for performance, things are much
> easier :)
I've hoped to leave my trace in history with a one-liner: "Inefficient
abstractions are a dime a dozen". Didn't seem to catch up at all :o).
> I really think the *only* *major* advantage of D over Python is speed.
> That's it.
In wake of the above, it's actually huge. If you can provide comparable
power for better speed, that's a very big deal. (Usually
dynamic/scripting languages are significantly more powerful because they
have fewer constraints.)
Andrei
More information about the Digitalmars-d
mailing list