[
Lists Home |
Date Index |
Thread Index
]
At 09:53 PM 5/7/2002 +0100, Bill de hÓra wrote:
>I don't for a moment dispute the usefulness of types, just /static/
>typing. Static typing as aid to programmer effectiveness is something of
>a myth, tho' it's very handy if you're a compiler or a runtime. Systems
>do get build with dynamically typed languages and seem to work fine;
>notably these languages are notoriously productive. If I'm wrong about
>this, that static typing vastly improves the lot of programmers, I'm
>happy to be corrected.
I think that depends a lot on what you are trying to accomplish.
Personally, I find untyped languages fine for slogging text around, which
most of us XML people do a lot. When I am doing typed operations on things
that actually have data types, I do find that types can prevent some
important errors.
Here's one example: I rewrote a library I had written so that it passed
URLs rather than nodes. In my initial rewrite, I missed several changes
that I should have made, and the result was a query library that was no
longer type valid. By correcting the type errors, I would have fixed the
problem. Only one problem - I was using an untyped implementation of
XQuery. Because of this, I had to run the library on data and find the
errors one at a time.
As you point out, static typing can definitely improve runtime performance.
Consider comparisons. In XQuery, $a = $b can mean a lot of things. If you
know both are singleton integers, you can just do an integer compare. If $b
is a sequence, you have to do existential quantification. If both are
strings, you need a string compare. The static type system can rewrite the
query to do the appropriate compare without needing to examine the data.
Without it, you have to pick your way through the data and use conditional
logic to figure out which comparison to use.
Jonathan
|