• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Static vs. Dynamic typing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static vs. Dynamic typing


  • Subject: Re: Static vs. Dynamic typing
  • From: Marco Scheurer <email@hidden>
  • Date: Wed, 2 Jul 2003 22:05:40 +0200

On Wednesday, July 2, 2003, at 10:15 AM, Rich Warren wrote:
I have a similar feeling about the static/dynamic issue. Static typing
creates compiler errors where dynamic typing would create runtime errors.
Compiler errors are always easier to catch than runtime errors. So, as much
as possible, I'd like to let the compiler do my testing for me.

That's wishful thinking.

All strong static typing advocates seem to fear the uncertainty of dynamic typing. While it's true that dynamic typing introduce a possible source of bugs, it is in practice not significant compared to everything else that can go wrong. And these errors are easily detected and corrected, compared to others such as off by one indices, memory management problems and so on. In addition, your objects are very often declared with a class information (e.g. NSArray * rather than id), so that the compiler will give you a warning. There's really nothing to fear.

[...] However, he goes on to say "The only guarantee of correctness, regardless of
whether your language is strongly or weakly typed, is whether it passes all
the tests that define the correctness of your program."

I have a problem with this. Testing can never guarantee a program's
correctness--at least not any programs of any real complexity. There is no
way to exhaustively test a program.

If your tests are written in advance and therefore specifies what your code is supposed to do in a formal way, then you've got a certain amount of certainty that your code is correct when the tests pass.

[...] It would be interesting to see serious research done on the relative
development costs of the entire lifecycle of projects done using static and
dynamic typing. It may be that dynamic typed projects are still
cheaper--even over the long haul. But I am not 100% convinced.

One such research was made in 1996. See for instance http://www.theadvisors.com/langcomparison.htm
According to this table, coding in Objective C is twice as productive as coding in C++.

On the other hand, programming Cocoa and Objective C is somewhat addictive.
I really am enjoying using the language, and the more I use it, the quieter
these nagging doubts become.

Good! In a previous life I used to believe that Ada was cool, if you can imagine that.

Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Static vs. Dynamic typing
      • From: Nadyne Mielke <email@hidden>
References: 
 >Static vs. Dynamic typing (From: Rich Warren <email@hidden>)

  • Prev by Date: Re: Drawing text with NSLayoutManager
  • Next by Date: Re: : -awakeFromNib, application_releasing ...
  • Previous by thread: Re: Static vs. Dynamic typing
  • Next by thread: Re: Static vs. Dynamic typing
  • Index(es):
    • Date
    • Thread