GSOC 2024 - Applying for: Building Swift Macros with WebAssembly

Hey guys, hope you're all well and doing great.

I really liked this idea here about compiling macro implementation code to WASM. It hits all the sweet spots I like, and I would very much like to work on it this GSOC!

Little bit about me: I graduated Cairo University less than a year ago with academic grade Excellence with Honors. I was bitten by the "Language bug" when I was in first year of university and since then I have been obsessed with any language-related infrastructure and just the idea of metaprogramming in general, whether it's compilers or VMs or Interpreters or debuggers or IDEs or static analyzers or code generators or anything really. I like to spend my free time reading PL-related books and research papers or watching talks, among the highlights is certainly Crafting Interpreters by the awesome Robert Nystrom and Compilers For Free by Tom Stuart, just to name a couple. I also contributed during GSOC 2023 to the truffleruby VM, working on the internal hash table memory representation.

If I may ask couple of questions about the project:

1- The project's main motivation section - as I understood it - is saying that pre-building macros speed up the build process of projects that use the macro, but is complicated by the fact that the macro needs to be built for each combination of OS and architecture and/or architecture-width.

My question is: Doesn't the compiler already know about the machine it's running on? Since macros only run on the development machine, surely the compiler is smart enough to build all macros once for the specific machine it's running on and then use the resulting binaries for every compilation of a project using the macro. What does WASM add to this? I'm guessing it's some sort of a cross-machine cache? Meaning the purpose of the project is to enable building a macro exactly once to WebAssembly and then the resulting WASM module will be published under a hash in some public repo that (later) a using compiler need only to pull and run, no re-building needed ever again (in theory). Is my guess correct? Does WASM add anything else (apart from maybe better sandboxing) to this?

2- What task/contribution/prototype/sample project is necessary/preferable for me to apply to the project?

3- Should I start writing the proposal right away? What should I focus on?

This is really directed to @Douglas_Gregor since he is listed as the potential mentor of the project, but if anyone want to think outloud with me they're more than welcome to !

Cheers,

-- Mostafa

6 Likes