I have mentioned it on HN before, but I strongly believe that bringing Python to the browser, especially via WASM, and going as far as bringing on a templating library, would allow Python to match things like C#'s Blazor, which honestly has been a productivity boost on web projects.<p>I'm totally all-in on WASM over JavaScript, unless your back-end is also JS/TS then no objection.<p>I could see Django benefitting greatly from being able to run template logic in-browser.
If my browser supports WebAssembly, I should be able to open my browser, forgo opening any actual web pages, and veer off into WebAssembly-land. From there perhaps there should be a package manager that lets me install packages (like Python, Java, Smalltalk, etc ) and switch to some sort of shell or launcher where I can enter a REPL for the selected language package. From there I could do anything.
very interesting. So all the declarative stuff, like various type descriptions and preconditions and such, can be precompiled.. (and i am not talking about type-hints/annotations). Maybe some of the meta-programming stuff too.<p>i was thinking some weeks ago that it may be time to "fork" python - as language - in a way to preserve the initial simplicity and clarity it did have and is losing faster and faster. But, nevermind. Will have to live with whatever there is.<p>edit: looking at the code, some things might be optimized but no idea if these are on critical path (like, that switch-by sq_idx, or 6 lines.append.. ), or whether func-calls are as expensive in Spy as they are in Cpy. But anyway, squeezing few percents is not the point.. if one needs magnitudes.
As someone that mainly codes in Python and only has rudimentary JS skills, I'm intrigued. The generative art pyscript demos mentioned in the blog post are really nice.<p>Using decorator calls to "compile" chunks of python code seems like an increasingly popular trend in ML (and presumably other numerically intensive code) - e.g., numba, jax.jit and triton.
SPy is a cool experiment which we should applaud, though perhaps it would be helpful to compare to ShedSkin, Nuitka, or maybe Numba along with Cython if the eventual goal is compile everything to Wasm.<p>I'd maybe quibble with "running natively on WebAssembly with speed in the same order of magnitude as Rust" given I expect that statement would be just as true if you replaced Rust on WebAssembly with the equivalent JavaScript.<p>But ultimately while I understand the motivation - at the beginning of my career before I discovered Python I wanted to write command line scripts in PHP because that was what I knew! - I think it is ultimately a dead end since by breaking from the Python ecosystem you end up having to compete against JavaScript which is not really that far from Python and has an existing library ecosystem to plug into.
Python is a fine language. It has a nice enough JIT compiler by now. Its structure is similar enough to JS to allow easy interop, and easy exposure of browser APIs exactly the way these APIs are exposed to JS.<p>But the power of Python currently <i>mostly</i> lies in its being a glue language. Python easily and neatly wraps things like numpy, scipy, polars, pytorch, etc, all implemented in native code. Not being able to use these would be a major limitation. But <i>being</i> able to use these would be a colossal change to the browsers' capabilities, security model, and, well, purpose.
Maybe Nim isn't python-like enough to count, but it compiles to C or JavaScript, which makes it sort of relevant to pythonishness in the browser.<p>Independently of its compilation flexibility, it's nice to work with. For example it was the first language that ever gave me compile error because there were cases that my switch statement didn't account for.
Other projects that tries to achieve the same: RustPython and py2wasm<p>So far my issue with pyiodide or other interpreted variants of python in wasm is the huge startup time especially if you need to install dependencies. The above projects i hope eventually reach a point where we can just compile everything
Author is right in their dismissive attitude of Pyodide, but their WASM-ward gaze is probably misplaced, too. Once you're talking about acceptability in terms of being "Python-like enough", you should really be considering a Python-like syntax for JS, which would suffice for a bunch of Python programmers (in particular those who only picked it up as a result of ill-considered advocacy by Python proponents who told them that e.g. Python is how science gets done).
I write a lot of Python, and I like it very much. But when it comes to the browser, what I don't like is compilation/build steps (yes, that includes Vue/React/Whatever builds). And that's why even I who don't like javascript very much will still be using it vanilla-style even if a compile-your-python-to-browser-wasm ever takes off.<p>That would still be nice to have some of those python libs to the browser though.
I have a Node background so I might be biased but... Why would you want python in the browser?<p>Like, I get the appeal of more languages beyond JavaScript for the frontend, but I'd have guessed this would mostly be attractive to people who like significantly different languages to js, like maybe something compiled and strongly typed.<p>Python and Javascript seem to be in the same ballpark of "interpreted scripty language grown larger". I don't think moving to python would give me a different enough language to warrant the cost of switching.