Record Types in Scala: Design and Evaluation

Detta är en Master-uppsats från KTH/Skolan för datavetenskap och kommunikation (CSC)

Författare: Olof Karlsson; [2017]

Nyckelord: Records; Types; Scala; Programming Languages;

Sammanfattning: A record type is a data type consisting of a collection of named fields that combines the flexibility of associative arrays in some dynamically typed languages with the safety guarantees and possible runtime performance of static typing. The structural typing of records is especially suitable for handling semi-structured data such as JSON and XML making efficient records an attractive choice for high-performance computing and large- scale data analytics. It has proven difficult to implement record types in Scala however. Existing libraries suffer from either severe compile-time penalties, large runtime over- head, or other restrictions in usability such as poor IDE integration and hard-to-compre- hend error-messages. This thesis provides a systematic description and comparison of both existing and possible new approaches to records in Scala and Dotty, a new compiler for the Scala 3 language. A novel benchmarking suite is presented, built on top of the Java Microbench- mark Harness (JMH), for measuring runtime and compile-time performance of records running on the Java Virtual Machine and currently supporting Scala, Dotty, Java and Whiteoak. To achieve field access times comparable to nominally typed classes, it is conjectured that width subtyping has to be restricted to explicit coercion and a compilation scheme for such record types is sketched. For unordered record types with width and depth sub- typing however, hashmap-based approaches are found to have the most attractive run- time performance characteristics. In particular, Dotty provides native support for such an implementation using structural refinement types that might strike a good balance be- tween flexibility and runtime performance for records in the future. 

  HÄR KAN DU HÄMTA UPPSATSEN I FULLTEXT. (följ länken till nästa sida)