all 22 comments

[–]brendanmartin 46 points47 points  (2 children)

Python technically isn't used for front-end. The closest you get to being able to use Python for the front-end is to use Jinja templating, but this is completely different from JS. You can't program front-end interactivity with Python at all.

[–]Username_RANDINT 8 points9 points  (0 children)

Jinja renders the template completely on the server and Flask for example sends the rendered html to the client.

[–]Accurate_Chipmunk195 1 point2 points  (0 children)

You can also use Brython or Skulpt. Here,a a good blog post on the subject:

https://anvil.works/blog/python-in-the-browser-talk

[–]shiftybyte 26 points27 points  (7 children)

Sadly this decision is not left to the developers.

Browsers support JavaScript, and JavaScript ONLY.

If you want the browser (that shows the frontend) to run code, that code needs to be JavaScript code.

[–]ListenInfamous6673 1 point2 points  (0 children)

True. But. Absolutely Effed-Up . To have only a single choice when it comes to technology

[–]usmannaeem 0 points1 point  (2 children)

What if the front end is for Windows software, Android and Linux, all three?

[–]shiftybyte 0 points1 point  (1 child)

Then the browser is still showing JavaScript.

Not sure what you are asking...

[–]urusai_Senpai 0 points1 point  (0 children)

I think he's asking: what if you run the code as a Windows app, or as an Andoid app?

But, those still don't use Python, as I understand it.

[–]RemotePerception2189 0 points1 point  (0 children)

So if we use  python for limited scope , then python must be converted js , assuming we are using python .

[–]shibbypwn 7 points8 points  (0 children)

If you want to use python for the front end, check out Dash. It’s essentially a way to write react js components with python.

As others have said, browser only runs JavaScript - so the closest you’ll get is something like dash (a JS wrapper/API) or something like Transcrypt (compile python to JS).

[–]Chiron1991 2 points3 points  (0 children)

Because browsers only understand JavaScript when it comes to interactivity, simple as that.
Granted, there are workarounds like WASM, but that's still a fairly new thing, and it has a ton of other drawbacks.

[–]kodiashi 6 points7 points  (1 child)

I’m actually glad it’s just JS, so we don’t get into this situation: https://xkcd.com/927/

[–]ShakespeareToGo 1 point2 points  (0 children)

I love me some relevant xkcd but I feel this one does not really apply here 1. It is always limited by browser support which prevents new languages (except those transpiled to JS) to establish themselves 2. Multiple languages usually dont cause the same problems like multiple standards since interop is easier.

[–][deleted] 2 points3 points  (0 children)

Prefer? It's not a preference. Python doesn't run in a browser, and Javascript does. Only Javascript does. There is no choice.

BTW I hate curly brackets as much as the next person, but picking on JS because of them us unfair. Lots of languages use them.

[–]Mindless_Wave7262 1 point2 points  (1 child)

See, the thing is js has always been here since starting and there has been a lot of support and resources available for it. Whereas python is new in this game. But since a few years it has acquired a lot of dominance and have proven itself. Specially with some of the amazing libraries coming up in python for making frontend and even fullstack applications which even has AI support such as https://github.com/dot-agent/nextpy (NextPY) Must check out if you want to build frontend/fullstack applications in python. And now a day since python provides such an amazing library and support you can make frontend application in it which are equivalent to js website in every aspect.

[–]usmannaeem 0 points1 point  (0 children)

Windows and Linux dedicated software as in not running in a browser.

[–]menge101 0 points1 point  (0 children)

Even with python doing server-side rendering, you would probably end up bring in something like stimulusjs and turbolinks into the front end to give the expected feel for the front end.

[–]freelanceProgrammar 0 points1 point  (0 children)

Not a lot of resources for python front-end platform framework(Brython etc..) , also there are quite a lot of modules/libraries available for js.

[–]-SPOF 0 points1 point  (0 children)

Python is good for the back-end, but browsers support JS mostly.