StaDyn Hybrid Dynamic and Static Typing Dynamic Languages Union Types Intersection Types Runtime Performance .Net
Fecha de publicación :
Dynamically typed languages have turned out to be suitable for different software development scenarios such as Web engineering, rapid prototyping, and the construction of applications where runtime adaptability is an important issue. In contrast, statically typed languages have undeniable advantages such as early type error detection and more opportunities for compiler optimizations. Since both approaches offer different benefits, hybrid statically and dynamically typed programming languages have emerged, and some statically typed languages have also incorporated dynamic typing capabilities. However, these languages do not perform static type inference on dynamically typed code, lacking the advantages provided for statically typed code. In this PhD we present StaDyn, a hybrid static and dynamic typing language that performs static type inference and type checking of both statically and dynamically typed references. StaDyn permits the straightforward development of adaptable software and rapid prototyping, offering early type error detection, improved runtime performance, and direct interoperation between dynamically and statically typed code. The programmer indicates whether high flexibility is required (dynamic typing) or stronger type checking (static) is preferred. It is also possible to combine both approaches, making parts of an application more flexible, whereas the rest of the program maintains its robustness and runtime performance. The key features of the proposed hybrid static and dynamic type system are a new interpretation of union and intersection types, the combination of syntax-directed and constraint-based type-checking, type inference of implicitly-typed dynamic and static references, and flow-sensitive type-checking. The type system has been implemented as an extension of a real full-fledged programming language such as C\# (StaDyn), obtaining the benefits of combining the .NET Framework and the proposed type system. We have compared the runtime performance and memory consumption of StaDyn with the most widespread hybrid dynamic and static typing programming languages for the .NET Framework 4. The assessment has been done with an ample set of benchmarks. StaDyn has shown the best performance in all the programs than use at least one dynamic reference, being 150% and 500% times faster executing dynamic and hybrid typing code, respectively. When no dynamic reference is used, the only language that performs better than StaDyn (2.5%) is the C# 4.0 production compiler, due to its static optimizations. Besides, StaDyn has showed the lowest memory consumption in every scenario. We have seen how the static type information gathered for dynamically typed references can be used to effectively improve the runtime performance and robustness of hybrid static and dynamic typing languages. Unlike the rest of the analyzed languages, StaDyn continues collecting type information of dynamically typed code. The type information inferred by the compiler is used to detect type errors at compile time when dynamic references are used. Moreover, this information is also used to optimize the generated code without any runtime memory cost.