Would You Use a 160KB Python Runtime in the Browser?

0
22
Asked By CreativeCloud9 On

I'm developing a Python compiler called Edge Python, which is aimed at reducing the bundle size for running Python in the browser to just around 160KB. This project uses Rust and targets WebAssembly, completely omitting CPython and other heavy interpreters. One of my main questions is: What's the max bundle size you would accept for a non-JS frontend runtime? Would 500KB or even 1MB be too much? Also, I want to know if bundle size really is the biggest barrier to using Python in the front-end, and what features Python would need to have to compete with JavaScript or TypeScript. Finally, does my idea of sharing memory between Python and JavaScript to improve DOM interaction sound feasible? I'm looking for honest opinions, critiques, or inspiration about whether there's a market for this innovation or if JS/TS will always rule.

13 Answers

Answered By CodeCzar On

Why not just go with JavaScript? Seems like an easier route.

Answered By DeepThinker On

You make a valid point about the ecosystem. Even if performance is there, it's all about the tooling and community support. Have you considered how this could integrate with existing Python libraries for tasks like data science or machine learning?

Answered By HistoryBuff88 On

There was a project back in 2008 by Mozilla for integrating Python and other languages into browsers, but it didn't pan out. It might be a tough road considering how messy web development already is.

WebDevWonder -

Wow, I had no idea! I'll have to dig into why that happened.

LearningLizard -

Yeah, I can’t imagine how complicating it’d be adding more languages to the mix!

Answered By PythonPal27 On

This project is really interesting! I'm curious about how you handle dynamic Python features in WASM, like object method calls. How do you compile something like `obj.method()`? Is it speculative or using a vtable-style lookup? Also, can we expect this to be open-source? I'd love to help out if you accept contributions!

EdgePythonDev -

Great question! Right now, I use a caching system for attribute lookups, but there's more to implement for full dynamic support. And yes, I'd love contributions! Check the GitHub link in my post.

Answered By SkepticalSamantha On

Not sure if I'd use Python in the browser. It seems like a single-threaded language would struggle there. If I’m choosing a new language, something typed like Rust seems like a better fit.

CleverCommenter -

But isn't JavaScript single-threaded too? Seems like you're piling on here!

Answered By AbstractArtist On

Not sure if I’d use Python for applications, but if it integrates well with CPython, it definitely opens up some intriguing use cases in the browser!

Answered By ThresholdExplorer On

Is this akin to what Brython is trying to achieve? Looks similar at first glance, but I’m interested in the differences.

Answered By DevilMayCare On

I might consider it because I prefer Python over JavaScript. But I still think for the heavy lifting, I'm going with WebAssembly compiled Rust. How does your runtime handle things like pip packages and imports? Is it 100% compatible with Python?

Answered By DartDevDude On

I actually prefer Dart over Python, but even Google struggled to get people to adopt Dart over JavaScript. It's hard to see Python making a significant impact in the frontend space.

Answered By RealisticRicky On

From my perspective, this seems like wasted effort. But hey, I appreciate the ambition!

OptimisticOscar -

I think there's potential here! It might be challenging, but worth exploring.

Answered By TechyTommy On

Honestly, I wouldn't consider using Python for frontend stuff, even if the bundle size is smaller. Just not my thing!

CuriousCat123 -

Can I ask why you're not a fan of Python in this context?

GigglyGiraffe -

Hahaha, sounds harsh, but hey, everyone has their preference!

Answered By FrontendFanatic On

Congrats on the progress! But personally, I don’t see myself switching to Python for frontend work. JavaScript frameworks are just too mature. Async behavior in JS also seems to work better for UI. But I'll definitely take some time to learn from your project!

Answered By ImpressedInquirer On

The 160KB size is nuts! If it works well at scale, that could be a game changer. Also, I think the shared memory approach could be a great way to avoid the performance issues of serialization in other frameworks.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.