TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A possible future of Python in the browser

149 点作者 milliams3 个月前

17 条评论

giancarlostoro3 个月前
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#&#x27;s Blazor, which honestly has been a productivity boost on web projects.<p>I&#x27;m totally all-in on WASM over JavaScript, unless your back-end is also JS&#x2F;TS then no objection.<p>I could see Django benefitting greatly from being able to run template logic in-browser.
评论 #43176646 未加载
评论 #43179060 未加载
评论 #43180457 未加载
评论 #43178802 未加载
评论 #43181552 未加载
supportengineer3 个月前
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.
评论 #43179657 未加载
评论 #43180277 未加载
评论 #43180299 未加载
评论 #43179798 未加载
svilen_dobrev3 个月前
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&#x2F;annotations). Maybe some of the meta-programming stuff too.<p>i was thinking some weeks ago that it may be time to &quot;fork&quot; 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.
评论 #43177614 未加载
评论 #43177627 未加载
评论 #43177549 未加载
ripped_britches3 个月前
I’m also super excited about wasm creating language democracy. I’m rooting for dart myself.
评论 #43177633 未加载
评论 #43179580 未加载
dimatura3 个月前
As someone that mainly codes in Python and only has rudimentary JS skills, I&#x27;m intrigued. The generative art pyscript demos mentioned in the blog post are really nice.<p>Using decorator calls to &quot;compile&quot; 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.
laurencerowe3 个月前
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&#x27;d maybe quibble with &quot;running natively on WebAssembly with speed in the same order of magnitude as Rust&quot; 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.
评论 #43182249 未加载
nine_k3 个月前
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&#x27; capabilities, security model, and, well, purpose.
评论 #43180920 未加载
Terretta3 个月前
In the meantime: <a href="https:&#x2F;&#x2F;marimo.app&#x2F;?mode=read" rel="nofollow">https:&#x2F;&#x2F;marimo.app&#x2F;?mode=read</a>
评论 #43182264 未加载
__MatrixMan__3 个月前
Maybe Nim isn&#x27;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&#x27;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&#x27;t account for.
评论 #43183440 未加载
评论 #43181164 未加载
rdedev3 个月前
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
cxr3 个月前
Author is right in their dismissive attitude of Pyodide, but their WASM-ward gaze is probably misplaced, too. Once you&#x27;re talking about acceptability in terms of being &quot;Python-like enough&quot;, 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).
JodieBenitez3 个月前
I write a lot of Python, and I like it very much. But when it comes to the browser, what I don&#x27;t like is compilation&#x2F;build steps (yes, that includes Vue&#x2F;React&#x2F;Whatever builds). And that&#x27;s why even I who don&#x27;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.
DeathArrow3 个月前
Why can&#x27;t regular Python code be compiled straight to WebAssembly?
评论 #43181718 未加载
khimaros3 个月前
i&#x27;m curious how SPy compares with Mojo, apart from the license. are they trying to solve the same problems?
gunian3 个月前
python in browser more of a pipe dream than me escaping slavery lmaooooo
kace913 个月前
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&#x27;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 &quot;interpreted scripty language grown larger&quot;. I don&#x27;t think moving to python would give me a different enough language to warrant the cost of switching.
评论 #43179800 未加载
评论 #43180338 未加载
评论 #43181671 未加载
评论 #43181625 未加载
评论 #43179208 未加载
评论 #43179284 未加载
评论 #43179176 未加载
dang3 个月前
[stub for offtopicness]
评论 #43179262 未加载
评论 #43176162 未加载
评论 #43176105 未加载