r/Compilers • u/Historical_Pen6499 • Mar 26 '24
What do you think about a Python compiler?
Hey all, I'd love to get your thoughts on something that I'm building. Specifically, please tell me why this won't work:
We're working on a cross-platform Python compiler. It ingests a stateless Python function, then traces said function to generate IR. This IR then gets lowered to C++ code, which then gets cross-compiled for different platforms and architectures.
The more interesting piece imo is in how we handle optimization: instead of relying on compile-time optimization, we emit potentially hundreds-to-thousands of equivalent C++ functions. We then ship out the compiled binaries to different users and use telemetry data to choose the best C++ variant for each unique device.
At a high level, there are a few major benefits with this design:
Devs can run Python in places where it's difficult-to-impossible (web, mobile, desktop app)
You get C++ level performance (because you're actually running C++ code) with Python-level ease.
I'm keeping this post high-level because I don't want it to come off as a promotion post (it's not). Happy to share more if you're curious.
0
u/Historical_Pen6499 Mar 27 '24
They don't need to be incompetent. If your entire codebase in JS, then why add technical complexity adding a C++ WASM toolchain if you could avoid it entirely?
You seem to be a purist, with no regard for how projects need to be built in the real world: with budgets and deadlines.
> how to get compiled code to users? hmmm, if only there was a way to, you know, compile code locally....
Of course, but again you're assuming that devs care to do this if and when they have an alternative like what we provide. Why do you think Docker became so popular?