Zachary DeVito - First-class Runtime Generation of High-performance Types using Exotypes
General problem: it's pretty convenient in dynamic languages to write generic operations over data structures, but doing this can be really slow.
Idea: when typechecking code, run stubs (e.g. methodmissing) to get code for a function, which is JITted into compiled code. This lets you do things like read in structure from a CSV.
ezyang: So, it's like metaprogramming, but hooked up with a JIT. But I guess one key thing is that instead of manipulating code, you're simply writing code as you would in a dynamic language, which is probably easier to understand.
Example: serialization and dynamic assembly generation. The key is that we can aggressively specialize on instances. For serialization, this involves fusion and removing generic dispatch from writes; for dynamic assembly generation, we generate an assembly template which just has things spliced in.
Conciseness (like dynamic languages) and performance (by specialization)
Emphasis here is on performance, rather that type correctness of generated code
Q: How do you represent memory layout in the system? Byte offsets? IR?
A: We use a type system for describing aggregate objects similarly to C. So we just linearly lay it out, and it figure out what padding is necessary. So you're generating struct description.
Q: In ICFP last year, they had a very good application: SQL code from F#. It could use this. We pointed out that you could use quasiquotation, by normalizing the code before doing codegen. So I see a lot of applications, but the key difference, is you say you don't need the type-checking. Have you thought of doing whole value normalization? That's similar to rewrites, which you do mention.
A: We haven't thought about transformation things on closed functions. We have a two step system where we provide binding hygiene (variable names renamed to avoid capture), but we recognize code generators often want to look like the code.
Q: This idea of doing trying templates, what did you have to do?
A: This is multistage. We don't generate strings, but we create ASTs, so at runtime we piece it together. Code is generated dynamically, so we don't do AOC, making us very flexible, and allowing optimizations.
A: We use LLVM to do code compilation, because it means we don't have to add overhead to the compiled code. But you could totally do this on JVM or CLR, and type providers are very similar.