The Artima Developer Community
Sponsored Link

Weblogs Forum
Programming with "Duh" Typing

370 replies on 371 pages. Most recent reply: Aug 8, 2007 9:54 AM by James Watson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 370 replies on 371 pages [ « | 1 ... 173 174 175 176 177 178 179 180 181 ... 371  | » ]
Erik Engbrecht

Posts: 210
Nickname: eengbrec
Registered: Apr, 2006

Re: Programming with "Duh" Typing Posted: Jul 17, 2007 4:44 AM
Reply to this message Reply
Advertisement
> > The problems I have had are: as I make changes, I often
> > don't realize that I have made some trivial error until
> 5
> > minutes into the test, when that code is first hit.
> This
> > is slow. Most of the time these are things that would
> > have been immediately flagged in a static language.
>
> Most probably it would not happen, and the reason is
> simple: in this day and age where most computer languages
> involve subtyping (i.e. inheritance from you OO folks),
> trivial errors can easily pass through through the
> subtyping mechanism. A static type system is almost
> useless in this case.
> Programming usually goes down two routes:
>
> 1) the problem at hand is trivial. In this case, a static
> type system won't help because the problem is trivial.
>
> 2) the problem at hand is quite complex. In this case, a
> static type won't help as well, because the code will
> usually involve lots of subclasses and interfaces.

I think you underestimate the penchant we mortals have for making stupid mistakes. Here's a common one (in rough Python):

<code>
#setup connection and execute query...
row = cursor.fetchone() #row is a tuple...
myObj.cost = row #should be row[0] to reference the first element of the tuple
</code>

I make those mistakes a lot. Maybe it comes from having a compiler yell at me for them, and having IDEs underline them, so I'm just sloppy in my typing.

The ones on the main paths of the code get weeded out quickly enough to not be too big of an issue. In that case unit testing is a reasonable substitute for static typing. But mistakes tend to linger in codepaths that you haven't tested. Ok, maybe tests should cover all code paths...but sometimes that takes too much time to do when the code is in a high state of flux and you don't know if it will ever really be used.

Flat View: This topic has 370 replies on 371 pages [ « | 173  174  175  176  177  178  179  180  181 | » ]
Topic: Programming with "Duh" Typing Previous Topic   Next Topic Topic: Python 3000 Plea for Help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use