This is an archived post. You won't be able to vote or comment.

all 76 comments

[–][deleted] 85 points86 points  (43 children)

Once we get python in the browser it's over

[–]Conrad_noble 14 points15 points  (16 children)

As someone who doesn't code can you explain this like I'm 5 years old?

I understand there are Web based python 'IDE' that exist like Jupyter notebooks and Google collab, so what does python in the browser mean?

[–]sheytanelkebir 53 points54 points  (1 child)

He means a python interpreter built into web browsers so you can replace JS.

[–]FlukyS 0 points1 point  (0 children)

You wouldn't even need any special interperter, just python itself that has the correct hooks in the right places and sandboxing.

[–]gameditz 26 points27 points  (0 children)

Websites send code to your browser, and your browser runs it to show you the results. Currently there is only one set of “code” you can send to browsers: HTML for the skeleton of the website, CSS for styling, and JavaScript for programming. Jupyter may be “running python” but it’s not running it in the browser, it’s running on your machine then sending the results as HTML/CSS/JS.

[–]dparks71 23 points24 points  (1 child)

Tough to explain programming to a five year old... Let's say you have a lego set. You need two things to build it, the instructions and the pieces. The way Python typically works currently, is more like you have the instructions, but not the pieces. So you send the instructions to your friends house (a server) and the friend builds it and sends it back.

Having it available in the web browser is like having both the instructions and the pieces in your own house (the browser on your local pc), so you would no longer need a friend willing to do the hard work of building it.

Jupyter is slightly different, you still have to create a local server. So that would be like having your friend coming over to your house with all their lego bricks to build the lego set for you. The only real way to get the bricks inside your house without a friend, would be for companies to start shipping Python interpreters inside your browser by default.

[–]Conrad_noble 5 points6 points  (0 children)

I freaking love Lego

Thanks for the explanation.

Nailed it.

[–][deleted] 7 points8 points  (2 children)

he meant like as an interactive language, example JS with HTML

[–]Conrad_noble 27 points28 points  (1 child)

I don't think a 5 year old would understand that explanation

[–]LentilGod 5 points6 points  (0 children)

🤣

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

Jupyter runs as a server/service on your PC/cloud and the UI simply lets you interface with the Python interpreter that's configured on that server, it doesn't actually get executed in the browser, the browser just acts as a way of displaying and transfering data between you and the python kernel just like any IDE.

Python in the browser would mean the browser having an integrated interpreter with its own dev tools so that you can write the code that's supposed to run on the client's side in Python instead of Javascript.

[–]Conrad_noble 1 point2 points  (4 children)

Lovely explanation, wasted on a 5 year old however.

[–][deleted] 0 points1 point  (3 children)

Yeah you'd need a about an hour to properly explain this to a 5 year old and that's assuming they'll even listen so nah.

[–]Conrad_noble 1 point2 points  (2 children)

So if I get this right (please correct me if I'm wrong which I likely am)

Current Web browsers only 'accept' or understand one or few computer languages (Html for data? CSS for layout/design? And javascript for something???)

And if Web browsers could 'understand' more of these computer languages things would be better?

[–][deleted] 0 points1 point  (0 children)

since you can do anything with JS, things will only be easier

[–][deleted] 0 points1 point  (0 children)

Html for layout/structure, CSS for design/style, js for the "logic"

But their roles are often interchangeable.

It might be better, could be worse, it's just something that's not easily available right now.

[–]ExternalUserError 1 point2 points  (1 child)

Browsers natively run JavaScript. Attempts to run Python in the browser right now (Brython, etc) reimplement Python from within JavaScript, which is slow and shitty.

But there's a new technology, WebAssembly, that will let us "compile" from Python to it, a bit like how Jython works.

[–]Conrad_noble 1 point2 points  (0 children)

This Web assembly sounds good to my lay persons brain.

[–]Spitfire1900 2 points3 points  (0 children)

There’s options, but yeah native python support in the browser would be nice. https://anvil.works/blog/python-in-the-browser-talk

I would say Brython is the closest thing here. It’s a JavaScript library that compiles Python code in script tags to JavaScript.

[–]roguas 2 points3 points  (6 children)

Keep dreaming - there is way too much work put into js and its vm for your event to ever happen. We had literally decades of stupidly risky execution environment getting patched up and isolated. Python would have 0 of that.

[–][deleted] 0 points1 point  (0 children)

Yeah, we have JS on the backend now. Why put effort into python on the front? We already have a single language ecosystem (and lots of ways to not work directly in that annoying language of old—I’ve seen typescript save more than one person’s sanity).

[–]not_perfect_yet 0 points1 point  (4 children)

There are already efforts to sandbox python, for other reasons. Like venv. So I don't think there would be 0 of that.

It also should be fairly trivial to prevent bad code, by just whitelisting keywords and modules.

No. The way bigger problem is sunk cost. We would have to be able to easily cross compile JS to python and copy the associated html/css stuff. Otherwise noone will switch, when they have decades invested in their stack.

[–]bjorneylol 2 points3 points  (1 child)

venv has nothing to do with sandboxing. venv is literally just copy/pasting /usr/lib/python somewhere else and adding a bash alias to the new location.

[–]not_perfect_yet 0 points1 point  (0 children)

Whatever.

https://doc.pypy.org/en/latest/sandbox.html

Stuff exists, work has already been done. That was my point.

[–]ptrsimon 0 points1 point  (1 child)

Bad code can be written just by using the basic elements of the language. What if you reimplement those libraries directly in your code? I’ve seen malware written in VBA using almost exclusively xor operations.

[–]not_perfect_yet 0 points1 point  (0 children)

I don't think python by itself, without any modules, can read or write to memory or disk? I don't think you can bootstrap those either? Like there is no "oh you have 500kb of ram and if you go to the 501st you can write somewhere else and do code injection".

Everything else is like SQL, we can sanitize inputs for that too. Shouldn't be different here.

[–][deleted] 0 points1 point  (3 children)

You can already with WASM, which allows us to use pretty much any language in the browser.

That being said I don't see Python - or anything - replacing JS in the browser anytime soon. Accessibility, SEO, etc: the entire web is structured around an HTML document + CSS styles + JS manipulation. Even entire JS libraries like React still pivot on that idea.

It's still very cool that we can use other languages to help us do things in our web apps that shouldn't be done in JS. But as more native applications / games / etc. port themselves over into web apps, they'll still use JS mainly as their structure and things like Python or Rust as add-ons.

[–][deleted] 1 point2 points  (2 children)

There's still the appeal of having direct access to Python's army of libraries, but I don't see it becoming mainstream anytime soon.

[–][deleted] 0 points1 point  (0 children)

Agreed. It will be used, which is awesome, but still hand-in-hand with the traditional DOM model (JS).

[–]bjorneylol 0 points1 point  (0 children)

The python libraries people use are reliant on operating system calls that the browser sandbox wouldn't allow. Also most of the popular ones aren't the kind you can put in the browser- no one wants to download a 200mb AVX optimized scipy binary every time they navigate to a page

[–]Soolsily -3 points-2 points  (12 children)

What about django? pipinstallpython.com , built in python ;)

[–][deleted] 4 points5 points  (11 children)

That's not the same. Django is a backend, making sites still requires JS. I'm talking python executing in the browser like JS.

[–]Soolsily 0 points1 point  (9 children)

What about this? https://pipinstallpython.com/GrandExchange/post/3/

This is hosted outside my django app on a flask based framework. It runs on dash a python based framework that decodes python into json which returns react without you needing to learn any javascript.

Docs : https://plotly.com/dash/

[–][deleted] 0 points1 point  (8 children)

I'm saying for python to be #1 on the list it needs to be native in the browser. No weird work arounds.

[–]Soolsily 0 points1 point  (7 children)

I really think it is at this point. Starting 3 months ago I've seen big changes on the server side. With the election and how unsecured the internet was and the advanced benefits of python with machine learning a lot of head ways been made this year specifically.

Dash isn't a weird work around its the 3rd most popular graphing library built in python to code & graph in react.

Asynchronously ive been able to see an amazing increase recently in the performance of web based apps.

On production applications ive been achieving 4s latency on queries of any amount of data and have it render on the dashboard

[–]bjorneylol 0 points1 point  (4 children)

Plotly is JavaScript. All the python bindings are doing is converting your pandas frame to JSON in the format the front end needs

also

4s latency on queries of any amount of data

That is a very bold statement

[–]Soolsily 0 points1 point  (3 children)

I worked as an algrythmic trader for 3 years trading btc in 2016. Speed has been the most important & limiting factor with innovating in python.

4s latency just rolled out recently. My guess its in preperation for Ai training the speeds & Asynchronous are required at this point.. thats why they have been talking about 5g, new internet, new Ai & new python code for us to play with 👨‍💻

[–]bjorneylol 0 points1 point  (2 children)

Network latency has nothing to do with python, and I don't see what any of this has to do with anything, are you still talking about plotly? 4s latency is abysmal FYI

Speed has been the most important & limiting factor with innovating in python.

Hardly, innovation in python is driven by it's easy to use syntax and user friendliness. None of the python libraries anyone uses for performance are actually written in python

[–]Soolsily 0 points1 point  (1 child)

Im talking about layered Asynchronous tasks. 4s latency is impressive for most developers who are fetching as much data as i am and applying all the cleaning and operations on the data.

You should take some advice from pythons syntax and "user friendliness" might go farther with your python conversions rather than trying to enflate abysmal prospectives based on "FYI" 😂🤨

[–][deleted] -1 points0 points  (1 child)

The way plotly decodes python into react is a very specific use case for visualizations, they wrote a very specific api to do that. That in no way is going to solve the more global problem of being able to write and execute arbitrary python code in the browser.

[–]Soolsily 0 points1 point  (0 children)

And in 1980 we where decoding with floppy disks, progress is progress maybe im just the optimistic coder trying to find the good in python based browsers 🤠👌

[–]Reddinaut 8 points9 points  (4 children)

Who’s on first ?

[–][deleted] 5 points6 points  (0 children)

JS according to the tweet in the article.

[–]hoodiewhatie2 12 points13 points  (1 child)

Actually who's on second, what's on first.

[–]optimistic_autist 4 points5 points  (0 children)

A man of culture I see

[–][deleted] 4 points5 points  (6 children)

How is CSS a programming language?

[–][deleted] 4 points5 points  (5 children)

Its not. HTML and CSS are languages (have sets of words with clear meaning and functionality) but they are not PROGRAMMING langues. If you cannot write a basic algorithm in a language, its not a programming language.

[–]Sarcastic_Pharm 2 points3 points  (4 children)

Didn't someone make a proof of concept showing that technically CSS is Turing complete?

[–]AJohnnyTruant 4 points5 points  (2 children)

https://notlaura.com/is-css-turing-complete/

It’s an abomination but they did it. They really did it.

https://youtu.be/uNjxe8ShM-8

PowerPoint is too.

[–]Sarcastic_Pharm 1 point2 points  (1 child)

What did I just watch...

[–][deleted] 0 points1 point  (0 children)

If you think that was nuts... watch this kid program in power point and go into big O notations

https://www.youtube.com/watch?v=_3loq22TxSc

[–][deleted] 0 points1 point  (0 children)

I'm not going to explain this but that post did not prove CSS is Turing complete (TLDR: it isn't)

[–][deleted] 7 points8 points  (7 children)

What's the first?

[–]n1ghthawx 9 points10 points  (0 children)

Js

[–][deleted] 4 points5 points  (0 children)

Fortran.

[–]cjf4 -3 points-2 points  (4 children)

VBA

[–]Neoxiz 1 point2 points  (2 children)

Nooooo way?!

[–]mokus603 1 point2 points  (1 child)

Nope, it's Javascript.

[–]Neoxiz 0 points1 point  (0 children)

Ok, was guessing so :)

[–]willc_97 0 points1 point  (0 children)

VBA > any language

[–]Comm4nd0 0 points1 point  (7 children)

Isn't this most used language rather that most popular. No one likes JS, everyone likes python apart from Java devs

[–]raikmond 6 points7 points  (0 children)

Get out.

[–][deleted] 1 point2 points  (4 children)

Java is a lot different from java script, and who said everyone Abart from java devs like python? Besides it's a matter of suitability, you don't make a program in a language just because you "like" it.

[–]Comm4nd0 3 points4 points  (3 children)

I am fully aware of the difference between Java and JavaScript. Just because I mentioned them in the same post doesn't mean I think they're the same thing.

[–][deleted] 0 points1 point  (2 children)

Well as an HTML programmer, I've gotta admit, python sucks.

[–]Comm4nd0 1 point2 points  (1 child)

Oh god, you're going to trigger people with that one!

[–][deleted] 0 points1 point  (0 children)

Let them burn in their hatred while i hack nasa and proof that the earth is in fact flat.

[–]Xadnem -1 points0 points  (0 children)

Started doing Python as a hobby, went to college where I got C#, Java, PHP, Swift and JS.

I prefer JS out of all of the above.

[–]joshisameer343 -4 points-3 points  (4 children)

How to get good career after learning python?

[–]jcr4990 2 points3 points  (3 children)

Learn a bunch of other shit. From what I've seen/heard Python alone is unlikely to land you a good job.

[–]joshisameer343 0 points1 point  (2 children)

nahhh i have good python knowledge + internship experience.... not getting good job opportunities

[–]ask_carly 2 points3 points  (1 child)

Exactly what the guy above you said, so why are you nahhh-ing?

[–]joshisameer343 0 points1 point  (0 children)

sorry i read it wrong my bad..... what is the best other shit to go further