Breaking Down PyScript.

PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of Pyodide, WASM, and modern web technologies. The PyScript framework provides users at every experience level with access to an expressive, easy-to-learn programming language with countless applications.

Up until now Python code was used only in the server which is a good thing by the way. Python code is going to run much quicker on a powerful server than it is in a browser on a laptop and so it makes sense that if there is a lot of processing to do, it should be done on the server.

Python in the browser is certainly a great idea for many Data Scientists who have invested a lot of time and effort in learning the language and the various libraries (Numpy, Pandas, Matplotlib, SciPy, Plotly…). Those of us who have spent a long time coding data visualizations in Jupyter Notebooks, for example, can now publish their work directly to the web with no need to worry about server frameworks like Django or Flask, without the need to configure servers or worry about deploying apps on Heroku or AWS or Azure.

What does this mean for developers?

  • The most obvious thing is that with PyScript, we can now write Python in HTML and build web applications. PyScript makes the power of Python accessible to a far greater audience of front-end developers and creators.

  • With PyScript, we no longer need to worry about deployment. PyScript provides the “architectural shift beyond the cloud.” Everything will happen in your web browser. As data scientists, we can share our dashboards and our models in an html file, which will run code whenever others open the file in a web browser.

One of the things that makes PyScript beautiful is that if you don't want to write your Python inside your Html you can link in your python file. For example

<py-script src="/python-file.py"> </py-script>

At the moment, PyScript is at the alpha development stage and so it will only improve but currently it is a little slow to get going. This certainly depends on the capability of the hardware it is running on.

Now to answer the question that started this article. Is PyScript here to replace JavaScript?.

My answer is No. While PyScript might be a wonderful advancement in modern web technology, I feel all technology both old and new all have their use cases. While PyScript would be an excellent tool for Data Scientist to add to their tool box, one thing we need to understand is that as far as browsers are concerned JavaScript will be the goto language. JavaScript is an entrenched language which is natively supported by the browsers and has a wealth of Frameworks and Libraries and more are still coming.

PyScript might be a great addition to Web Development but i feel it is no where near replacing JavaScript.

Let me Know what you feel in the comments below.

0
Subscribe to my newsletter

Read articles from Agbakosi Adeoluwa directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Agbakosi Adeoluwa
Agbakosi Adeoluwa

I am a developer from Nigeria. My stacks include Web Dev ( Full Stack ) and Data Science ( MLOps ).