The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
Bridging Static and Dynamic Typing
by Christopher Diggins
April 13, 2006
Michael Feathers recently suggested that maybe static typing is a form of bad coupling which we could do without. Well in C++ at least you can bridge static typing and dynamic typing.


Okay I lured you in, but I'll have to admit what I am about to propose here isn't elegant. C++ support for both generic programming and dynamically typed programming is extremely rudimentary, however I think there is something to take away.

The bridge I am talking about is as follows:

  template<typename T = ootl::object>
  class priority_queue {
     void push(T value, int priority);
     T pop();
     bool is_empty();
In this example, ootl::object is my dynamically typed variant class which is available at but you can just as easily use boost::any (which is slower, but perhaps a bit safer).

So what do you think? Dynamically typed, or statically typed, its your choice when you use templates.

Talk Back!

Have an opinion? Readers have already posted 1 comment about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at

This weblog entry is Copyright © 2006 Christopher Diggins. All rights reserved.

Sponsored Links


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