Optional Static Typing

Rocco Moretti roccomoretti at hotpop.com
Thu Dec 23 18:44:59 CET 2004


John Roth wrote:
>  
> One of the comments on Artima asks a rather profound
> question: static typing is an answer. What's the question?
> (That's a paraphrase.)
> 
> The answer that everyone seems to give is that it
> prevents errors and clarifies the program.

<shrug> It might just be me, but I thought it was to simplify code 
analysis and compilation. (That is, for the use of static typing in 
general, not for Python in particular.)

Looking at C, it's doubtful error prevention and program clarification 
was a serious objective in the static typing system. It's more 
reasonable to conclude that C is statically typed because it allows the 
compiler to more easily allocate 1 vs 2 vs 8 bytes for a particular 
variable, and to make sure the proper addition opcodes get put down.

Now whether this would be useful for Python is an open question.

> Many of the supposed advantages simply aren't there
> when you go to the discipline of writing a test and then
> writing exactly the code needed to make the test pass, and
> not one keystroke more.
...
> This isn't to say TDD is the be-all and end-all of
> correctness. 

Right. And unit tests don't do anything for people who don't use them. 
The question is, should Guido state "TDD is the one true way to program 
in Python.", or should concessions be made in the language design for 
those who don't "drink the TDD Kool-aide".

> So the conclusion here is that static typing is an attempt
> to make programming safe for people that shouldn't be
> programming in the first place. 

I rebut it thusly: "elitist bastard." <wink and a half>

One of the draws of Python is that it's welcoming to newcomers and 
programmers of all talents. You don't have to be an "uber-programmer" to 
use it and use it well. Should we hobble it to suit poor programmers? 
No. But that's no reason why it can't be made to be easier and safer to 
use for the hobbyist when it doesn't compromise usefulness for the 
power-programmer. (My opinion) Python shouldn't have a sign on the door 
saying: "You must be this 'leet to enter."

Will static typing be a boon for Python? Is it necessary? Or is it the 
trailhead on the road to Hades? <shrug> Only time will tell.



More information about the Python-list mailing list