Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP

From: David Simmons (
Date: 07/16/04

Date: Thu, 15 Jul 2004 22:16:35 -0700

"Dmitry A. Kazakov" <> wrote in message
> On Tue, 13 Jul 2004 13:34 +0100 (BST), Dave Harris wrote:
> > (Dmitry A. Kazakov) wrote (abridged):
> >> And another advantage of static typing shows itself: in a dynamically
> >> typed language it is not an easy task to have overloading (aka
> >> statically polymorphic subroutines). Either you need a global
> >> God-like "*" working for all cases or you have to send messages
> >> in parallel and have some voting mechanics to select one answer from
> >> the chorus. What if I need to define one "*" local? Would it
> >> effect tasks running in parallel. How to isolate changes made in
> >> other contexts? Brr!
> >
> > It sounds like you are talking about multimethods.


> Those and also free functions.
> > Several dynamic
> > languages support them, including Cecil, Dylan and S#.
> >
> > It's not especially difficult. The stuff a static language does at
> > time a dynamic language does at run-time. Scoping rules can still apply
> > that's what you want.
> Hmm, to maintain a run-time stack of signatures (overloading each other)
> and match them each time a message is sent. That is neither easy nor
> efficient.


It is quite straight forward and mechanically easy to do; execution is
extremely efficient. In fact the performance is faster to or on-par/equal to
that of c++ in many cases.

What is hard, is inlining the functions dynamically and exploiting
structural/representational type information (as opposed to
behavioral/contractual type information). That is tricky and does require
clever design that begins with recognizing that you don't inline machine
code, you inline the IL (opcodes). And that, requires that you have a well
thought out opcode instruction set that retains the semantics of the
translated program to enable efficient semantic analysis and optimization
based on both runtime heuristics and quasi-static analysis.

> What do they do in case of signatures clash discovered at run-time?
> MessageTooUndersdood? (:-))

There is never a clash. The algorithms for binding are completely
deterministic. Unless the language is badly designed...

-- Dave S. [] (designer of S#)

> --
> Regards,
> Dmitry A. Kazakov