TY - GEN
T1 - Multi-stage programming in the large with staged classes
AU - Parreaux, Lionel
AU - Shaikhha, Amir
PY - 2020/11/16
Y1 - 2020/11/16
N2 - Multi-stage programming (MSP) holds great promise, allowing the reliable generation of specialized, partially-evaluated code with static type- A nd scope-safety guarantees. Yet, we argue that MSP has not reached its full potential yet, as it has been traditionally limited to generating expressions, and has lacked principled facilities for generating modular programs and data structures. In that sense, we argue that MSP has been reserved for programming "in the small,"focused on generating efficient kernels of computation on the scale of single function bodies. We present a novel technique called staged classes, which extends MSP with the ability to manipulate class definitions as first-class constructs. This lets programmers use MSP "in the large,"on the level of applications, rather than mere functions. This way, applications can be designed in an abstract and modular way without runtime cost, as staged classes guarantee the removal of all staging-time abstractions, resulting in the generation of efficient specialized modules and data structures. We describe the design of a prototype relational database system in Scala, which uses several stages of runtime compilation to maximize the efficiency of query execution and data storage. We also show that staged classes can be used for defining type- A nd scope-safe implementations of type providers.
AB - Multi-stage programming (MSP) holds great promise, allowing the reliable generation of specialized, partially-evaluated code with static type- A nd scope-safety guarantees. Yet, we argue that MSP has not reached its full potential yet, as it has been traditionally limited to generating expressions, and has lacked principled facilities for generating modular programs and data structures. In that sense, we argue that MSP has been reserved for programming "in the small,"focused on generating efficient kernels of computation on the scale of single function bodies. We present a novel technique called staged classes, which extends MSP with the ability to manipulate class definitions as first-class constructs. This lets programmers use MSP "in the large,"on the level of applications, rather than mere functions. This way, applications can be designed in an abstract and modular way without runtime cost, as staged classes guarantee the removal of all staging-time abstractions, resulting in the generation of efficient specialized modules and data structures. We describe the design of a prototype relational database system in Scala, which uses several stages of runtime compilation to maximize the efficiency of query execution and data storage. We also show that staged classes can be used for defining type- A nd scope-safe implementations of type providers.
KW - multi-stage programming
KW - squid
KW - staged classes
UR - http://www.scopus.com/inward/record.url?scp=85097644267&partnerID=8YFLogxK
U2 - 10.1145/3425898.3426961
DO - 10.1145/3425898.3426961
M3 - Conference contribution
AN - SCOPUS:85097644267
T3 - Proceedings of the International ACM SIGPLAN Conference on Generative Programming & Component Engineering
SP - 35
EP - 49
BT - GPCE 2020 - Proceedings of the 19th ACM SIGPLAN International Conference on Generative Programming
A2 - Erwig, Martin
A2 - Gray, Jeff
PB - ACM
T2 - 19th ACM SIGPLAN International Conference on Generative Programming
Y2 - 16 November 2020 through 17 November 2020
ER -