Live data from Hacker News

Brython: an implementation of Python 3 running in the browser

github.com

21–30 of 76 posts

Re: Brython: an implementation of Python 3 running in the browser

#21
Past related threads:

Brython: Python in the Browser - https://news.ycombinator.com/item?id=26781461 - April 2021 (1 comment)

Brython – A Python 3 implementation for client-side web programming - https://news.ycombinator.com/item?id=23746067 - July 2020 (214 comments)

Brython – Client-side web programming in Python - https://news.ycombinator.com/item?id=15914805 - Dec 2017 (1 comment)

Brython – A Python 3 implementation for client-side web programming - https://news.ycombinator.com/item?id=9792536 - June 2015 (60 comments)

A Python 3 implementation for client-side web programming - https://news.ycombinator.com/item?id=5807059 - June 2013 (117 comments)

Brython, Python in the browser - https://news.ycombinator.com/item?id=5133047 - Jan 2013 (65 comments)

Brython - Python to Javascript translator - https://news.ycombinator.com/item?id=4923530 - Dec 2012 (68 comments)

(That last thread and the June 2013 thread are good for anyone worried that HN has become more negative lately...)

Re: Brython: an implementation of Python 3 running in the browser

#22
post #2

I discovered this about a month ago, and it deserves to go up to the sky. The GitHub page is linked at the end. Some articles/content that relates to this ([4] is pretty cool and definitely check it out, so is [6]): [1] https://brython.info/static_doc/en/intro.html [2] https://towardsdatascience.com/run-python-code-on-websites-e... [3] https://stackabuse.com/an-introductory-guide-to-brython [4] https://rayluo.github.…

Great post and great comment but please don't put "Show HN" on submissions like this. As rahimnathwani pointed out, that signifies that the project is your personal work.

https://news.ycombinator.com/showhn.html

Re: Brython: an implementation of Python 3 running in the browser

#23
post #18

I found the following article and associated presentation to be a great overview of the options for this kind of thing: https://anvil.works/blog/python-in-the-browser-talk Transcrypt's ( https://github.com/QQuick/Transcrypt ) approach made the most sense for me. The project seems to be a heroic effort by one guy.

Yeah Transcrypt is interesting! There’s even a book that shows you how to use it with React [0]. Personally I think mithril.js would be a better fit than React because JSX isn’t supported.

[0] http://www.transcrypt.org/pdfs/rtptutorial.pdf

Re: Brython: an implementation of Python 3 running in the browser

#24

I'm hoping web assembly eventually completely replaces javascript. It would be amazing if we could theoretically compile any language down to be browser compatible.

That’s already pretty much the case. Python has been though it’s not fast and the stack size limit is problematic. https://github.com/pyodide/pyodide Pyodide is used in https://jupyterlite.readthedocs.io/ Maybe things will improve with web assembly GC, though it will require work to port GC languages to it.

Guido mentioned he was focusing work on CPython to make Python faster

Re: Brython: an implementation of Python 3 running in the browser

#25
post #21

Past related threads: Brython: Python in the Browser - https://news.ycombinator.com/item?id=26781461 - April 2021 (1 comment) Brython – A Python 3 implementation for client-side web programming - https://news.ycombinator.com/item?id=23746067 - July 2020 (214 comments) Brython – Client-side web programming in Python - https://news.ycombinator.com/item?id=15914805 - Dec 2017 (1 comment) Brython – A Python 3 implementat…

Wow I wasn't aware of those. But apart from the 2020 post, the others are pre-TS. Brython seems to have come a long way since TS came in

Re: Brython: an implementation of Python 3 running in the browser

#26
post #6
post #5

Brython has been around a long time, at least 7 or 8 years. While I love Python and I'm not a particularly big JS fan, I feel like if Brython didn't really make a dent before ES6 and TypeScript, then it will be really hard to do it now. Does anyone know what the biggest Brython project/app is? Can we see it in production other than a simple hello world?

Yeah, it has been there for quite some time, but has really started getting off the ground in about mid-late 2019 which is strange, since like you mentioned, the advent of TS. But slowly a lot of interest has been brewing over it, it's growing faster than ever, and has been attracting users/contributors a LOT only since the start of last year. https://academy.cs.cmu.edu/ This is Carnegie Mellon's academy website, run…

Python was itself around for years, predating PHP by several years even, before it took off; PHP got big much quicker. Ruby was around for several years before Rails helped it take off outside of Japan. So, that doesn't mean Brython will take off now, but it does at least suggest it's possible.

Re: Brython: an implementation of Python 3 running in the browser

#28
After reading this thread and being frustrated by the pretty useless exceptions Brython gives, I switched over to using Pyodide (which took 5 minutes, both libraries are pretty simple). There is a huge improvement on usability with Pyodide. It doesn't wrap JavaScript objects in lots of additional structures like Brython does and it actually gives stack traces that end in user code!

I've only been exploring Pyodide for the 10 minutes since I switched over and discovered these two pieces.

I'm curious if there's a good reason to use Brython over Pyodide.

Edit: Ok one weird thing with Pyodide is that I cannot use subscripts with JavaScript objects in Python. I have to use dot accessors. So not `row["age"]` but `row.age`. Kinda weird, not too Pythonic.

Re: Brython: an implementation of Python 3 running in the browser

#29

This project will transpile python code to JavaScript code instead of something WASM-based, like pyodide [0]. What are there the performance and usability consequences of each approach (py to js vs. py to wasm)? [0] https://github.com/pyodide/pyodide

(Disclosure: I'm a maintainer of https://skulpt.org , another Python-in-the-browser runtime, as well as a Python web framework/dev environment that uses it, https://anvil.works ) The short answer is that basically all the current Python-in-the-browser implementations (and there are a few!) predate widespread support of WASM. But even once WASM is a thing, you get a choice between: 1. Compile a full Python environment…

Maybe a small Python engine (MicroPython, Snek [2]) on WebAssembly might also fit some niche uses.

MicroPython has a version working in the browser using unicorn.js (which emulates ARM CPU). [3]

[1] https://micropython.org/ [2] https://sneklang.org/ [3] https://micropython.org/unicorn/

Re: Brython: an implementation of Python 3 running in the browser

#30

After reading this thread and being frustrated by the pretty useless exceptions Brython gives, I switched over to using Pyodide (which took 5 minutes, both libraries are pretty simple). There is a huge improvement on usability with Pyodide. It doesn't wrap JavaScript objects in lots of additional structures like Brython does and it actually gives stack traces that end in user code! I've only been exploring Pyodide fo…

Thank you for sharing Pyodide. Please consider adding a link to things like this. Cheers!

https://github.com/pyodide/pyodide

Post reply on HN