[Python-3000] duck typing
Alex Martelli
aleaxit at gmail.com
Sun May 7 18:31:44 CEST 2006
On May 6, 2006, at 6:37 PM, Greg Ewing wrote:
...
> The disadvantages associated with very strong type systems
> arise because of their strength, not whether they are
> static or dynamic. A language with the same type system
> as Java, but enforced at run time instead of compile
> time, would be just as annoying to use.
Java's typechecking IS enforced at runtime just about each and every
time you cast something (I'm told the need for casting has diminished
with Java 1.5's generics, but I have no experience of 1.5; earlier,
casts abounded each time you used containers, since they contained
Object instances).
Personally, I find the typesystems of such FP languages as Haskell to
be the second best thing to Python's -- and yet it's extremely strong
and totally compile-time. So, I guess what really annoys me in Java
is the enforced _redundancy_, the impossibility of applying DRY... I
don't really _need_ such conveniences as changing types on the fly,
and writing typeclasses to ensure protocol adaptation is as good or
better for me than relying on method-homonimy (and I'm sure generic-
functions and multimethods would be just as good, too). But I want
to say things *once, and only once* -- Haskell's types excel at
letting me do that (and the compiler infers things so I don't have to
repeat myself), Python's are fine (and the runtime safeguards me
against my errors), but Java's mandatory redundance, mixed
compiletime/runtime checks, etc, just don't make me happy:-(.
Alex
More information about the Python-3000
mailing list