Design and implementation of an efficient hybrid dynamic and static typing language

Dynamic languages are suitable for developing specific applications where runtime adaptability is an important issue. On the contrary, statically typed languages commonly provide better compile‐time type error detection and more opportunities for compiler optimizations. Because both approaches offer different benefits, there exist programming languages that support hybrid dynamic and static typing. However, the existing hybrid typing languages commonly do not gather type information of dynamic references at compile time, missing opportunities for improving compile‐time error detection and runtime performance. Therefore, we propose some design principles to implement hybrid typing languages that continue gathering type information of dynamically typed references. This type information is used to perform compile‐time type checking of the dynamically typed code and improve its runtime performance. As an example, we have implemented a hybrid typing language following the proposed design principles. We have evaluated the runtime performance and memory consumption of the generated code. The average performance of the dynamic and hybrid typing code is at least 2.53× and 4.51× better than the related approaches for the same platform, consuming less memory resources. Copyright © 2014 John Wiley & Sons, Ltd.

[1]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[2]  Eelco Visser,et al.  Turning dynamic typing into static typing by program specialization in a compiler front-end for Octave , 2003, Proceedings Third IEEE International Workshop on Source Code Analysis and Manipulation.

[3]  Jan Vitek,et al.  Thorn: robust, concurrent, extensible scripting on the JVM , 2009, OOPSLA '09.

[4]  Andrew W. Appel,et al.  Modern Compiler Implementation in Java , 1997 .

[5]  Reinhold Weicker,et al.  Dhrystone: a synthetic systems programming benchmark , 1984, CACM.

[6]  Raúl Izquierdo,et al.  The Runtime Performance of invokedynamic: An Evaluation with a Java Library , 2014, IEEE Software.

[7]  Gary T. Leavens,et al.  A Type Notation for Scheme , 2005 .

[8]  Péricles Rafael Oliveira Alves,et al.  Just-in-time value specialization , 2013, Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

[9]  吴树峰 从学徒到大师之路--读《 The Pragmatic Programmer, From Journeyman to Master》 , 2007 .

[10]  Peter Sommerlad,et al.  Pattern-Oriented Software Architecture: A System of Patterns: John Wiley & Sons , 1987 .

[11]  Ravi Chugh,et al.  Dependent types for JavaScript , 2012, OOPSLA '12.

[12]  Sameer Kulkarni,et al.  Mitigating the compiler optimization phase-ordering problem using machine learning , 2012, OOPSLA '12.

[13]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 2001, TOPL.

[14]  Robert W. Sebesta,et al.  Programming Language Processors in Java: Compilers and Interpreters: AND Concepts of Programming Languages , 2000 .

[15]  John C. Mitchell,et al.  F-bounded polymorphism for object-oriented programming , 1989, FPCA.

[16]  Satish R. Thatte Quasi-static typing , 1989, POPL '90.

[17]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[18]  Francisco Ortin,et al.  Modularizing Different Responsibilities into Separate Parallel Hierarchies , 2011, ENASE.

[19]  Lieven Eeckhout,et al.  Statistically rigorous java performance evaluation , 2007, OOPSLA.

[20]  Miguel Garcia,et al.  Supporting dynamic and static typing by means of union and intersection types , 2010, 2010 IEEE International Conference on Progress in Informatics and Computing.

[21]  M Mernik,et al.  When and how to develop domain-specific languages , 2005, CSUR.

[22]  Parasuram Anantharam Programming ruby , 2001, SOEN.

[23]  Jan Vitek,et al.  Integrating typed and untyped code in a scripting language , 2010, POPL '10.

[24]  Michael M. Vitousek Design and Implementation of Gnarly , a Hybrid-Typed Programming Language , 2010 .

[25]  Francisco Ortin,et al.  Union and intersection types to support both dynamic and static typing , 2011, Inf. Process. Lett..

[26]  Mariangiola Dezani-Ciancaglini,et al.  Intersection and Union Types: Syntax and Semantics , 1995, Inf. Comput..

[27]  Jeffrey S. Foster,et al.  Static type inference for Ruby , 2009, SAC '09.

[28]  Miguel A. Labrador,et al.  A hybrid class- and prototype-based object model to support language-neutral structural intercession , 2014, Inf. Softw. Technol..

[29]  Erik Meijer Dynamic typing when needed: The end of the cold war between programming languages , 2004 .

[30]  Martin Odersky,et al.  Pizza into Java: translating theory into practice , 1997, POPL '97.

[31]  David J. Lilja,et al.  Measuring computer performance : A practitioner's guide , 2000 .

[32]  Francisco Ortin,et al.  Efficient support of dynamic inheritance for class- and prototype-based languages , 2013, J. Syst. Softw..

[33]  Brian Dorn,et al.  Design and implementation of a reusable type inference engine and its application to Scheme , 2005 .

[34]  Andrew W. Appel,et al.  Modern Compiler Implementation in Java, 2nd edition , 2002 .

[35]  Mike Paterson,et al.  Linear unification , 1976, STOC '76.

[36]  Juan Manuel Cueva Lovelle,et al.  Dynamic adaptation of application aspects , 2004, J. Syst. Softw..

[37]  Michel Pelletier,et al.  The Zope Book , 2001 .

[38]  Francisco Ortin Type Inference to Optimize a Hybrid Statically and Dynamically Typed Language , 2011, Comput. J..

[39]  Francisco Ortin,et al.  Achieving Multiple Dispatch in Hybrid Statically and Dynamically Typed Languages , 2013, WorldCIST.

[40]  Manish Vachharajani,et al.  Gradual typing with unification-based inference , 2008, DLS '08.

[41]  Terence Parr The Definitive ANTLR Reference: Building Domain-Specific Languages , 2007 .

[42]  Walid Taha,et al.  Gradual Typing for Objects , 2007, ECOOP.

[43]  Martín Abadi,et al.  Dynamic typing in polymorphic languages , 1995, Journal of Functional Programming.

[44]  Juan Manuel Cueva Lovelle,et al.  Optimizing Reflective Primitives of Dynamic Languages , 2008, Int. J. Softw. Eng. Knowl. Eng..

[45]  B. J. Ferro Castro,et al.  Pattern-Oriented Software Architecture: A System of Patterns , 2009 .

[46]  Julian Rathke,et al.  Preemptive Type Checking in Dynamically Typed Languages , 2013, ICTAC.

[47]  Luca Cardelli,et al.  Basic Polymorphic Typechecking , 1987, Sci. Comput. Program..

[48]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

[49]  B. Pierce Programming with intersection types and bounded polymorphism , 1992 .

[50]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[51]  Robert Cartwright,et al.  Soft typing , 2004, SIGP.

[52]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[53]  James Gil de Lamadrid,et al.  Core FOBS: A hybrid functional and object-oriented language , 2012, Comput. Lang. Syst. Struct..

[54]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[55]  Fred L. Drake,et al.  The Python Language Reference Manual , 1999 .

[56]  J. Baltasar García Pérez-Schofield,et al.  Efficient virtual machine support of runtime structural reflection , 2009, Sci. Comput. Program..

[57]  Sophia Drossopoulou,et al.  Towards Type Inference for JavaScript , 2005, ECOOP.

[58]  Brian Hackett,et al.  Fast and precise hybrid type inference for JavaScript , 2012, PLDI '12.

[59]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[60]  Dave Thomas,et al.  Agile Web Development with Rails , 2005 .

[61]  Gavin M. Bierman,et al.  Adding Dynamic Types to C# , 2010, ECOOP.

[62]  David Thomas,et al.  Agile web development with Rails - a pragmatic guide , 2005 .

[63]  J. Baltasar García Pérez-Schofield,et al.  Including both static and dynamic typing in the same programming language , 2010, IET Softw..

[64]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[65]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

[66]  Ravi Chugh,et al.  Nested refinements: a logic for duck typing , 2012, POPL '12.

[67]  Gilad Bracha Pluggable Type Systems , 2004 .

[68]  Stephen N. Freund,et al.  Hybrid Types , Invariants , and Refinements For Imperative Objects , 2006 .

[69]  Jon Sigel,et al.  CORBA Fundamentals and Programming , 1996 .

[70]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[71]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[72]  Francisco Ortin,et al.  A Type Safe Design to Allow the Separation of Different Responsibilities into Parallel Hierarchies , 2011, ENASE.

[73]  Elena Zucca,et al.  Introducing safe unknown types in Java-like languages , 2006, SAC '06.

[74]  Neville Grech Pre-emptive type checking in dynamically typed programs , 2013 .

[75]  Juan Manuel Cueva Lovelle,et al.  Design Patterns for Teaching Type Checking in a Compiler Construction Course , 2007, IEEE Transactions on Education.