Achieving Multiple Dispatch in Hybrid Statically and Dynamically Typed Languages

Conference paper
Part of the Advances in Intelligent Systems and Computing book series (AISC, volume 206)


Multiple dispatch is a feature provided by some programming languages, in which the actual method to be executed is dynamically determined by the runtime types of its arguments. Although some programming languages such as CLOS, Xtend and Dylan provide this feature, many widespread languages such as Java, C# and C++ only support single dispatch by means of dynamic binding. Therefore, different implementation techniques are commonly used to obtain multiple dispatch from within these single-dispatch languages. We propose a new approach to obtain multiple dispatch in single-dispatch hybrid static and dynamic typing languages. Using C# as an example, the proposed approach is compared with the existing ones, considering factors such as software maintainability and readability, code size, parameter generalization, compile-time type checking, and runtime performance. The example implementation of the hybrid statically and dynamically typed approach in .Net has shown a runtime performance 1.26 times lower than the statically typed approach, and 6.27 times higher than the dynamically type one.


Multiple dispatch multi-method hybrid static and dynamic typing dynamic binding reflection method overload 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Chambers, C.: Object-Oriented Multi-Methods in Cecil. In: ECOOP 1992. LNCS, vol. 615, pp. 33–56. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  2. 2.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Longman, Boston (1995)Google Scholar
  3. 3.
    Ortin, F., Zapico, D., Cueva, J.M.: Design Patterns for Teaching Type Checking in a Compiler Construction Course. IEEE Transactions on Education 50(3), 273–283 (2007)CrossRefGoogle Scholar
  4. 4.
    Torgersen, M.: The Expression Problem Revisited. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  5. 5.
    Ortin, F., Lopez, B., Perez-Schofield, J.B.G.: Separating Adaptable Persistence Attributes through Computational Reflection. IEEE Software 21(6), 41–49 (2004)CrossRefGoogle Scholar
  6. 6.
    Maes, P.: Computational Reflection. Ph.D. Thesis, Laboratory for Artificial Intelligence, Vrije Universiteit, Amsterdam, the Netherlands (1987)Google Scholar
  7. 7.
    Meijer, E., Drayton, P.: Static Typing Where Possible, Dynamic Typing When Needed. In: OOPSLA Workshop on Revival of Dynamic Languages, pp. 1–6 (2004)Google Scholar
  8. 8.
    Bierman, G., Meijer, E., Torgersen, M.: Adding Dynamic Types to C#. In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 76–100. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  9. 9.
    Ortin, F., Zapico, D., Perez-Schofield, J.B.G., Garcia, M.: Including both Static and Dynamic Typing in the same Programming Language. IET Software 4(4), 268–282 (2010)CrossRefGoogle Scholar
  10. 10.
    Ortin, F., Redondo, J.M., Perez-Schofield, J.B.G.: Efficient virtual machine support of runtime structural reflection. Science of Computer Programming 74(10), 836–860 (2009)MathSciNetzbMATHCrossRefGoogle Scholar
  11. 11.
    Redondo, J.M., Ortin, F., Cueva, J.M.: Optimizing Reflective Primitives of Dynamic Languages. International Journal of Software Engineering and Knowledge Engineering 18(6), 759–783 (2008)CrossRefGoogle Scholar
  12. 12.
    Georges, A., Buytaert, D., Eeckhout, L.: Statistically rigorous Java performance evaluation. In: Object-Oriented Programming Systems and Applications, pp. 57–76. ACM, New York (2007)Google Scholar
  13. 13.
    Redondo, J.M., Ortin, F.: Efficient Support of Dynamic Inheritance for Class and Prototype-based Languages. Journal of Software and Systems, 1–24 (2012) (to be published)Google Scholar
  14. 14.
    Cunei, A., Vitek, J.: PolyD: a flexible dispatching framework. In: Object-Oriented Programming Systems and Applications, pp. 487–503. ACM, New York (2005)Google Scholar
  15. 15.
    Chiles, B., Turner, A.: Dynamic Language Runtime,
  16. 16.
    Ortin, F., Garcia, M.: Union and intersection types to support both dynamic and static typing. Information Processing Letters 111(6), 278–286 (2011)MathSciNetCrossRefGoogle Scholar
  17. 17.
    Ortin, F.: Type Inference to Optimize a Hybrid Statically and Dynamically Typed Language. The Computer Journal 54(11), 1901–1924 (2011)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  1. 1.Computer Science EditorialUniversity of OviedoOviedoSpain

Personalised recommendations