Achieving Multiple Dispatch in Hybrid Statically and Dynamically Typed Languages
- 1.6k Downloads
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.
KeywordsMultiple dispatch multi-method hybrid static and dynamic typing dynamic binding reflection method overload
Unable to display preview. Download preview PDF.
- 2.Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Longman, Boston (1995)Google Scholar
- 6.Maes, P.: Computational Reflection. Ph.D. Thesis, Laboratory for Artificial Intelligence, Vrije Universiteit, Amsterdam, the Netherlands (1987)Google Scholar
- 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
- 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.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.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.Chiles, B., Turner, A.: Dynamic Language Runtime, http://www.codeplex.com/Download?ProjectName=dlr&DownloadId=127512