What do you think about Pyscript? You can get started for free here: bit.ly/40de9vS You can also try Anaconda's other offerings and sign up for the Starter Tier level: bit.ly/3ULu8jA ----- Note: These are sponsored links. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you!🙏
It seems to be really slow compared to JavaScript, or even Brython. I think for now I will stick with JavaScript for the front end and Python for the back end, much as I hate JavaScript.
nobody asked for that. it's hard enough for front end developers to stuck in javascript that doesn't tell you things going wrong until you put it in production, I think we really need to move away from dynamic typed languages or any languages that don't tell you to fxxk off when you use a function like a variable. Data types, data structures and algorithms are the basics of computer science, learn a little before you call yourself a software engineer, we dont need code monkeys any more we have AI that can write code now!
I don’t think it’s meant to compete with popular JavaScript frameworks. I have more experience with JavaScript than I do with Python, but I work in data analysis, and I definitely see how PyScript can benefit data scientists and analysts.
This is an incredible project. Just look at the popularity of streamlit. There is a giant demand to quickly standup python applications with a web front end.
It doesn't make sense from a performance standpoint at first. It's really useful for the litany of libraries for data-science in specific, for example, lots of deep-learning code is written in Python and becomes "instantly-embeddable" in the same manner that JS is for modern web-applications. Doubly exciting since it connects to JS as well! I'm looking forward to what people make with this tech!
@@roccociccone597 Gazillion of useful and high quality librairies, backed by trillion dollar companies, rules data science, ML, scripting, neat web frameworks etc. It's not a "hype" at all, it doesn't take you to think "it's special" to be used.
I’m not sure I’d use this very often. But, suppose you do data analysis or machine learning in python. With this you could just call the models directly. That seems nice. And 100 million other applications. If you have other better tools you can use those, but it’s nice if people can use what they’re familiar with. Then again, it would have been nice if many of us happened to be familiar with the same stuff instead of having 50 choices. Maybe I can scribble together a new language and make everyone adopt that…
Awesome video! The 2D game was one of my proof-of-concept apps. The game itself is one of the demos that's bundled with the Pyxel engine, with a few modifications like adding a mute button. For what it's worth, experimental support for Pyxel is built into the current release of the Pyodide runtime (0.23), but I'd be a little cautious deploying with that at scale - because of how simulated infinite loops work in Emscripten (i.e. doing while(True) without locking everything up), some dead Python frames are left on the stack, leading to a slow memory leak. It's definitely stable enough to play around with an have a good time - but watch PyScript and Pyodide for stability updates.
if you are into gamedev, check out Lua game engines. My 8years old daughter started with Python but I have redirected her to other language like Lua...due to Python's speed limitation for something as complex as a game engine. Lua has > 90% similar syntax as Python so the learning curve is rather low.
WOW... Im new to this and this video gave me more clues to add to the scrypt and site im trying to build by self educating me... More videos like this please using PyScript and how to incorporate images on background, images on buttons, boxes that show images, calculators... that would be awesome for me to learn and get knowledge faster while listening to the videos and understanding the mechanics of this new world to me... Thank you so much Patrick cheers
@PatrickLoeber Lovely video and cool showcase, I look forward to exploring. *Important note:* I'd recommend reuploading with your ChatGPT API key blurred.
A few concerns: Loading time, downloading dependencies every time instead of caching them. Security: For example you showed it using open ai, surely anybody could view the source of the page and steal your api key. I'm not sure I see the point just yet, though capable it's still using js and there's no way around that I guess.
loadingtime: browser cache security: wtf? no! can you steal api keys right now in js browsers? oc he hardcoded for simplicity, but no one ever hardcodes api keys in production code
@@tidy5156 If the code to call the api is in the frontend, then the key variables is there, and thus the key is also in the source code. The only other scenario, is getting a key through a request after user auth. The way applications can secure a frontend API key somewhat (Which google's api does) is to whitelist your domain as the only one that can be called from with a particular apikey
@@tidy5156 loadingtime: Most user don't care if their 2nd time is fast but if their 1st time is fast. If your page loads for like 60s on a slow 3G connection, good luck getting any users at all.
@@GoldenretriverYT Of course the subsequent times matter and people care about it, otherwise nobody would use a CDN, would do server side caching and would make sure to prevent browser caching.
@@heroe1486 Of course people care, but the most important one is the first visit. This is proven by many studies and even small increases in load time can reduce the rate of users that stay on your site dramatically (cant link those studies because of youtubes filters). Also, your CDN wont make your python runtime suddenly load in 3s instead of 60s. Slow connections are still widespread issue and CDNs cant make the throughput rate increase from 400kb/s to 100mb/s
@@Godrose you get a whole data science ecosystem to run in your browser...something Javascript can't...that's the point, this is not some web framework, that is not the point of Pyscript.
About the only real use I see for this right now is to take RenPY games and host them on the web. Most all the things you would want to use python for, aren't really intended for use on the front end but instead in standalone applications and on servers for heavy data processing.
I'm the kind of person who started with python. If I see { } for anything other than a json, a dict, an f-string or templating language all I want to do is puke. JS is the king of web dev, yes. But If I have the option to build a web app with html, css, django and pure python... I will choose python any day of the week.
@@moodmaker2796 good luck with that when a single whitespace breaks your code you don't like curly brackets, but you like "self" everywhere in your code ?
@@guruware8612 I love self. It's pink and cute and it's always where it's supposed to be. Curly brackets are messy, they get lost and you never quite see which one belongs where! I HATE THEM! :D
The problem that I have with pyscript is that from the beginning, the majority of the code that I try doesn't work even when I copy, verbatim, from youtube videos. Even before pyscript website was updated to having you login to see anything, I had literally copy and pasted right from their own sample code and.....didn't work most the time. I keep wanting to love it but it has barely worked for me and when it did work or didn't work I had no idea why, especially when I was using their sample code. Was there a typo I couldn't find? Was there some update to their JS scripts that we link to that impacted the code in their samples? I only hope that they can get it working! I just tried it again now with some pretty simple code and it didn't work.
@@sheriffasasi354 if its already a problem of version in the very beginning, then dump it, but fast what "real" programing language is version dependent ? new features ok, but old stuff needs to work as it was, or are you willing to rewrite your whole codebase every month ?
The GPU question is in my mind too. I don't see any reason this wouldn't work in any app since you just need to add the library link to any page head. For me that's Svelte.
So basically they're using WebAssembly to run a Python interpreter... Isn't that kinda like putting a diesel generator inside the trunk of Tesla to generate its electricity, and then saying "Now you can run Tesla's without electricity! What a breakthrough!"
I guess so, you can maybe great a page with a fake token and see if it's exposed. But since pyscript is a frontend framework, it seems logical that the API key will be visible. A workaround would be to ask the user to enter their key in a textbox and then use it on their behalf. Since it's frontend, their API key will never reach your own server, so it's kind of safe
ofc, it would be safe - if all the logic would be on BE (server). FE client implements only user logic, business login shouldn't be implemented in browser
so we have to be online to use this, right? i can't go out in a field with 0 internet and be using this to control some embedded raspberry pi device with no internet access, right? darn.
@@RedStone576 I was talking about,when the app is in production. I would expect low latency from python compared to js is all. And i am prety sure about it.
@@maverick5056 don't think so, this thing still uses javascript to bind the dom with the wasm. so accounting the amount js and wasm being used plus the parsing of the pythonscript on each dom action... raw javascript will obv performs better than this
@@RedStone576 That would be true. But i think if the Dev's could pull something like sveltejs or quick kind of stuff with pyscript, then it might be really great. Js definitely is irreplaceable in the current situation..
Im expecting a compiled language instead python to run in wasm as an alternative to js, because it will be must faster than, pyscript is a nice idea as an alternative but they're still running on python interpreter, just like js with js engine, i hope there will more and more language as an alternative to js for web development
people complain about the story of babylon, the story to explain the existence of many languages but now we invent a new language every day, or combinations of them - the future looks much brighter now don't we have already enough 'frameworks', why now add python to the mix there was a time, i was writing webpages with notepad, they worked and did their job --> providing information now we get scroll effects, fancy animated buttons, adverts, annoying cookie-popups - where is the info hidden i was searching for ? now we need responsive design, because people stare into their smartphones 16 hours a day but python is here, jay ! that's what i think about PyScript, you asked...
So if I use this for the front end and Django for the backend. Does that mean I still have to use Javascript? Or can I just use ONLY python for future web apps?
you dont have to use this, no need. Javascript is as easy as python anyway id rate it on the same level of difficulty, JS has maybe a little bit more syntax but thats it both are EZ.
Alot of people already built frameworks like this in Python and other languanges. At this point they should just make a framework that can transpile their code into javascript. So they can use the JavaScript libraries, etc. But this would be alot slower and tedious. Like everytime you save your Python file it will automatically update the JavaScript file.
What do you think about Pyscript? You can get started for free here: bit.ly/40de9vS
You can also try Anaconda's other offerings and sign up for the Starter Tier level: bit.ly/3ULu8jA
-----
Note: These are sponsored links. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you!🙏
It seems to be really slow compared to JavaScript, or even Brython. I think for now I will stick with JavaScript for the front end and Python for the back end, much as I hate JavaScript.
This was a mistake
I tried to avoid Javascript as much as possible. I really waited for this and this will enable some real cool projects while it improves over time.
nobody asked for that. it's hard enough for front end developers to stuck in javascript that doesn't tell you things going wrong until you put it in production, I think we really need to move away from dynamic typed languages or any languages that don't tell you to fxxk off when you use a function like a variable. Data types, data structures and algorithms are the basics of computer science, learn a little before you call yourself a software engineer, we dont need code monkeys any more we have AI that can write code now!
is it possible to use packges like turtle,tkinter and ursina?
I love it how the web development industry keeps on inventing new ways to render the exact same thing; just to keep us busy...
It allows you to have a python runtime in a browser🥶, it is not meant to compute UI
That’s exactly my point. Thank you
with python comes datascience libraries in your web dev ... wich is huge
well at least it is not javascript
@@flannn6 within the span of time that you have typed that comment 2 new javascript frameworks just got idealized by someone.
As much as this is unique and welcome, I can't imagine Pyscript becoming big among the other 100 web frameworks that get released each month.
you're missing the point
I don’t think it’s meant to compete with popular JavaScript frameworks. I have more experience with JavaScript than I do with Python, but I work in data analysis, and I definitely see how PyScript can benefit data scientists and analysts.
This is exactly what Matlab guys said when Python started to come out 20 years ago ahahah
@@Louisianish You don't want to do your data analysis in the frontend though
This is competing with python notebooks, not with web frameworks.
You can finally build nicely organized and user friendly python scripts.
This is an incredible project. Just look at the popularity of streamlit. There is a giant demand to quickly standup python applications with a web front end.
Yes correct. Streamlit, Gradio, Pywebio are some of the popular frameworks.
- "WASM is great because it allows near-native performance by skipping the js interpreter"
- "Let's use it to run a python interpreter!"
yessss finally someone said it
It doesn't make sense from a performance standpoint at first. It's really useful for the litany of libraries for data-science in specific, for example, lots of deep-learning code is written in Python and becomes "instantly-embeddable" in the same manner that JS is for modern web-applications. Doubly exciting since it connects to JS as well! I'm looking forward to what people make with this tech!
@@SirPlotsalot I use python for pygame, on that note I'm going to have to wait for pygbag to release.
I don't know why python is so hyped to be honest. It's fine but nothing special
@@roccociccone597 Gazillion of useful and high quality librairies, backed by trillion dollar companies, rules data science, ML, scripting, neat web frameworks etc.
It's not a "hype" at all, it doesn't take you to think "it's special" to be used.
Finally JS is becoming quite fast but to balance that humanity decided to run python in the browser. 😂
New py versions will be faster
The Python interpreter isn’t in JS, it’s (probably Rust/C++ that was compiled to) WebAssembly
I think we can use python as a complemente to javascript
JavaScript sucks, I hope it dies sooner the better. Python is much more elegant /sarcasm, but kinda isn't?
speed isn't the main issue with JS
Really excited from the video. Thanks Patrick for the great intro.
Looking forward for more tutorials about pyscript🎉
Crazy Stuff!!!Unbelievable!!!!Next level Python!!!Thank you so much!!!
i want to cry this is much soo much easier and understandable then sometimes javascript with their frameworks
I’m not sure I’d use this very often. But, suppose you do data analysis or machine learning in python. With this you could just call the models directly. That seems nice.
And 100 million other applications. If you have other better tools you can use those, but it’s nice if people can use what they’re familiar with. Then again, it would have been nice if many of us happened to be familiar with the same stuff instead of having 50 choices. Maybe I can scribble together a new language and make everyone adopt that…
Great demo! Thanks Patrick.
finally someone covering pyscript!
Awesome video! The 2D game was one of my proof-of-concept apps. The game itself is one of the demos that's bundled with the Pyxel engine, with a few modifications like adding a mute button.
For what it's worth, experimental support for Pyxel is built into the current release of the Pyodide runtime (0.23), but I'd be a little cautious deploying with that at scale - because of how simulated infinite loops work in Emscripten (i.e. doing while(True) without locking everything up), some dead Python frames are left on the stack, leading to a slow memory leak.
It's definitely stable enough to play around with an have a good time - but watch PyScript and Pyodide for stability updates.
if you are into gamedev, check out Lua game engines. My 8years old daughter started with Python but I have redirected her to other language like Lua...due to Python's speed limitation for something as complex as a game engine. Lua has > 90% similar syntax as Python so the learning curve is rather low.
WOW... Im new to this and this video gave me more clues to add to the scrypt and site im trying to build by self educating me... More videos like this please using PyScript and how to incorporate images on background, images on buttons, boxes that show images, calculators... that would be awesome for me to learn and get knowledge faster while listening to the videos and understanding the mechanics of this new world to me... Thank you so much Patrick cheers
@PatrickLoeber Lovely video and cool showcase, I look forward to exploring. *Important note:* I'd recommend reuploading with your ChatGPT API key blurred.
woah really helpfull mr patrick
im student from indonesia
A few concerns: Loading time, downloading dependencies every time instead of caching them.
Security: For example you showed it using open ai, surely anybody could view the source of the page and steal your api key.
I'm not sure I see the point just yet, though capable it's still using js and there's no way around that I guess.
loadingtime: browser cache
security: wtf? no! can you steal api keys right now in js browsers? oc he hardcoded for simplicity, but no one ever hardcodes api keys in production code
@@tidy5156 If the code to call the api is in the frontend, then the key variables is there, and thus the key is also in the source code. The only other scenario, is getting a key through a request after user auth. The way applications can secure a frontend API key somewhat (Which google's api does) is to whitelist your domain as the only one that can be called from with a particular apikey
@@tidy5156
loadingtime: Most user don't care if their 2nd time is fast but if their 1st time is fast. If your page loads for like 60s on a slow 3G connection, good luck getting any users at all.
@@GoldenretriverYT Of course the subsequent times matter and people care about it, otherwise nobody would use a CDN, would do server side caching and would make sure to prevent browser caching.
@@heroe1486 Of course people care, but the most important one is the first visit. This is proven by many studies and even small increases in load time can reduce the rate of users that stay on your site dramatically (cant link those studies because of youtubes filters).
Also, your CDN wont make your python runtime suddenly load in 3s instead of 60s. Slow connections are still widespread issue and CDNs cant make the throughput rate increase from 400kb/s to 100mb/s
One thing I don't understand ids why PyScript is enclosed bewteen tags instead of
Maybe technical not allow to do that 🧐
This is exciting. May have to use this as well as your next to last video with LangChain
Did you intend to publish your OpenAI API key?
Awesome video! thanks. So, we can't currently deploy this in our custom domains? or can we?
how to take values from inputs / forms?
Excellent, thanks for explaining this so well.
Looks interesting. What's its usefulness given the plethora of already existing frameworks that do this better faster easier?
@@anthonyrussano What problem does it solve then?
@@Godrose you get a whole data science ecosystem to run in your browser...something Javascript can't...that's the point, this is not some web framework, that is not the point of Pyscript.
@@encapsulatio I was referring to the clickbait title.
About the only real use I see for this right now is to take RenPY games and host them on the web.
Most all the things you would want to use python for, aren't really intended for use on the front end but instead in standalone applications and on servers for heavy data processing.
Should one consider using this instead of Flask?
Is the python code / OpenAI API key visible to a user? Wouldn't think leak your credentials?
What about breaking changes? Browser based Python seems pointless until its guaranteed that the code will run properly on future versions.
super useful! Subscribed.
If it doesn't have 12 billion dependencies that all break with every single update then it's never going to be able to compete with TypeScript.
Is it safe to show your OpenAI API key here?
Was looking for away to PM, but cats out the bag.
Not a user of OpenAI API. But they should have menas to re-generate token invalidating old ones.
Finally python in HTML, the end is near for javascript.
Lmao this project among other projects have been around a long time ago and still JS is so popular especially that we've got TS now
Awesome project. But the big question is, what python running on a browser environment can bring new to the table that the Javascript cannot.
I would like if javascript would disappear
The data science ecosystem which Python provides and JS doesn't . Personally I see myself using it in Svelte apps.
I'm the kind of person who started with python. If I see { } for anything other than a json, a dict, an f-string or templating language all I want to do is puke.
JS is the king of web dev, yes. But If I have the option to build a web app with html, css, django and pure python... I will choose python any day of the week.
@@moodmaker2796 good luck with that when a single whitespace breaks your code
you don't like curly brackets, but you like "self" everywhere in your code ?
@@guruware8612 I love self. It's pink and cute and it's always where it's supposed to be.
Curly brackets are messy, they get lost and you never quite see which one belongs where! I HATE THEM! :D
Such a great video ❤
Thanks Patrick... Does pyscript support events listening and handling?
nope, but it has robust whitespace support, and is "self"-aware
Is the python code running client side?
Shalom evening howdy how.
GOSH, thank you so much for sharing.
is this gonna replace js?
Do the ML packages leverage the GPU?
How is pyscript essentially different to say, streamlit?
Can you work with this offline? I want to integrate pyscript on my offline wifi projects in rasbery pi
9:35 hurts my eyes to see a non-async get request in the browser
Thanks for your wonderful video sir. Please create a video on how to connect Pyscript with Database and make input output web apps
is there a way to install module?
Yes!!! lets finally grap JS and put it in the garbage bin. And then reach to another garbage bin and use python.
I can’t get it. Why do I need Python in the frontend? Which problems it may solve?
Will it be possible to include python in Laravel blade?
How does this compare to Brython?
The problem that I have with pyscript is that from the beginning, the majority of the code that I try doesn't work even when I copy, verbatim, from youtube videos. Even before pyscript website was updated to having you login to see anything, I had literally copy and pasted right from their own sample code and.....didn't work most the time.
I keep wanting to love it but it has barely worked for me and when it did work or didn't work I had no idea why, especially when I was using their sample code. Was there a typo I couldn't find? Was there some update to their JS scripts that we link to that impacted the code in their samples?
I only hope that they can get it working!
I just tried it again now with some pretty simple code and it didn't work.
Maybe u're using the wrong version. I don't use pyScript though
@@sheriffasasi354 if its already a problem of version in the very beginning, then dump it, but fast
what "real" programing language is version dependent ?
new features ok, but old stuff needs to work as it was, or are you willing to rewrite your whole codebase every month ?
Oh what a great work! I have two questions. Can we access the gpu by this? And can we use it in reactjs?
The GPU question is in my mind too. I don't see any reason this wouldn't work in any app since you just need to add the library link to any page head. For me that's Svelte.
Very nice! Thank you!
So basically they're using WebAssembly to run a Python interpreter...
Isn't that kinda like putting a diesel generator inside the trunk of Tesla to generate its electricity, and then saying "Now you can run Tesla's without electricity! What a breakthrough!"
looks kind of like good old java days 😅
It's an amazing tutorial, so thank you for that Sir. Can I host my html with Py-Script at a none Python web hosting company?
Great! Thank you a lot. If I publish the page with my openAI token, will this one be public?
I guess so, you can maybe great a page with a fake token and see if it's exposed. But since pyscript is a frontend framework, it seems logical that the API key will be visible. A workaround would be to ask the user to enter their key in a textbox and then use it on their behalf. Since it's frontend, their API key will never reach your own server, so it's kind of safe
ofc, it would be safe - if all the logic would be on BE (server). FE client implements only user logic, business login shouldn't be implemented in browser
Thanks, Patrick! But how do you deploy this thing? Or is it possible?
In theory, any web server than can serve html files would work. My go to choice would be nginx, but other options are available.
so we have to be online to use this, right? i can't go out in a field with 0 internet and be using this to control some embedded raspberry pi device with no internet access, right?
darn.
I don't understand. it didn't work for at all its like html didn't recognize it ....help me.
Is it gonna be lightweight?
Cant know for sure rn, but compared to javascript, python does seem like winning in that category.
no wtf, you're downloading the whole python intreperter on each document load how the hell can that be lightweight
@@RedStone576 I was talking about,when the app is in production.
I would expect low latency from python compared to js is all.
And i am prety sure about it.
@@maverick5056 don't think so, this thing still uses javascript to bind the dom with the wasm. so accounting the amount js and wasm being used plus the parsing of the pythonscript on each dom action... raw javascript will obv performs better than this
@@RedStone576 That would be true.
But i think if the Dev's could pull something like sveltejs or quick kind of stuff with pyscript, then it might be really great.
Js definitely is irreplaceable in the current situation..
Great tutorials! However I'm not sure if its a good idea to publicly share your ChatGPT API Key!!
yep probably a bad idea but its free and even if it wasn't he probably changed it already
How was is it? Because everytime I finish coding something in python I want to rebuild it in nextjs immediately 😅
please make a playlist on pyscript machine learning apps
7:02 Actually it’s showing the date not time…..
This is awesome!
How does this compare to using FastAPI or Django/Flask?
Those are back-end. This is front-end. So you would likely use both in your project.
Great! I made similar for php.
amazing, what about pygame
So it's like GWT, only with Python instead of Java?
not even close
can we make mobile app with this?
Im expecting a compiled language instead python to run in wasm as an alternative to js, because it will be must faster than, pyscript is a nice idea as an alternative but they're still running on python interpreter, just like js with js engine, i hope there will more and more language as an alternative to js for web development
Kotlin will definitely be that language hopefully.
It's compiled and has a lot of cool syntactical sugar and is easy to read and use
people complain about the story of babylon, the story to explain the existence of many languages
but now we invent a new language every day, or combinations of them - the future looks much brighter now
don't we have already enough 'frameworks', why now add python to the mix
there was a time, i was writing webpages with notepad, they worked and did their job --> providing information
now we get scroll effects, fancy animated buttons, adverts, annoying cookie-popups - where is the info hidden i was searching for ?
now we need responsive design, because people stare into their smartphones 16 hours a day
but python is here, jay !
that's what i think about PyScript, you asked...
Jquery for python?
I have a question. Do we even need it? If yes, then why?
Ohhh another shiny tool! gotta learn
Can the banner ads/managers that are normally written in JavaScript be replaced with Pyscript?
can this be a faster/efficient alternative to php?
probably, and no
So if I use this for the front end and Django for the backend. Does that mean I still have to use Javascript? Or can I just use ONLY python for future web apps?
you dont have to use this, no need. Javascript is as easy as python anyway id rate it on the same level of difficulty, JS has maybe a little bit more syntax but thats it both are EZ.
Thank @Patrick for this video.
I am not sure if this project, at this current stage, is production read?
According to the docs it's still in alpha and under heavy development, so it will take some more time. But for fun demo apps it's already pretty cool
I think until we see frameworks build on top of it we won't see it in production level.
What about Streamlit?
First thing to come to mind: Easier deployment of pre-trained machine learning models
this is so damnnn awesomeeee
Excelente, muchas gracias
why people try to run python anywhere?
I am curious how new frameworks based on pyscript look like
This is 🔥
it costs notable time do download and load pyodide, which the bigger drawback now
Cool feature I've noticed, the onclick event with py-click its super cool, way more easier than Javascript
Why do their cookies even have an option for “sale of information” in todays day?
This just looks like a new vector for adversary attack on applications...
What if we want to use any python library sir..
holy hell why is it so loud???? the volume on this video is very very high compared to other videos...
soon python will take over every tech space
Another Python solution in search of a problem :))
damn this looks interesting
Why not use VS code!
I cant stop myself from asking this question: What problem does it solve?
Very awesome.
Alot of people already built frameworks like this in Python and other languanges. At this point they should just make a framework that can transpile their code into javascript. So they can use the JavaScript libraries, etc. But this would be alot slower and tedious. Like everytime you save your Python file it will automatically update the JavaScript file.
OHH YES I FUCKING LOOOOVE MORE BLOAT IN MY BROWSER
Pywarez code is hot.
No more django or flask??????