{"id":2830,"date":"2025-04-03T07:02:22","date_gmt":"2025-04-03T07:02:22","guid":{"rendered":"https:\/\/mailitics.com\/index.php\/2025\/04\/03\/pyscript-vs-javascript-a-battle-of-web-titans\/"},"modified":"2025-04-03T07:02:22","modified_gmt":"2025-04-03T07:02:22","slug":"pyscript-vs-javascript-a-battle-of-web-titans","status":"publish","type":"post","link":"https:\/\/mailitics.com\/index.php\/2025\/04\/03\/pyscript-vs-javascript-a-battle-of-web-titans\/","title":{"rendered":"PyScript vs. JavaScript: A Battle of Web Titans"},"content":{"rendered":"<p>    PyScript vs. JavaScript: A Battle of Web Titans<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<p class=\"wp-block-paragraph\"><mdspan datatext=\"el1743466709098\" class=\"mdspan-comment\">We\u2019re delving<\/mdspan> into frontend web development today, and you might be thinking: what does this have to do with <a href=\"https:\/\/towardsdatascience.com\/tag\/data-science\/\" title=\"Data Science\">Data Science<\/a>? Why is Towards Data Science publishing a post related to web dev?<\/p>\n<p class=\"wp-block-paragraph\">Well, because data science isn\u2019t only about building powerful models, engaging in advanced analytics, or cleaning and transforming data\u2014<strong>presenting the results is also a key part of our job<\/strong>. And there are several ways to do it: PowerPoint presentations, interactive dashboards (like Tableau), or, as you\u2019ve guessed, through a website.<\/p>\n<p class=\"wp-block-paragraph\">Speaking from personal experience, I work daily on developing the website we use to present our data-driven results. Using a website instead of PowerPoints or Tableau has many advantages, with <strong>freedom and customization<\/strong> being the biggest ones.<\/p>\n<p class=\"wp-block-paragraph\">Even though I\u2019ve come to (kind of) enjoy JavaScript, it will never match the fun of coding in Python. Luckily, at FOSDEM, I learned about <strong>PyScript<\/strong>, and to my surprise, it\u2019s not as alpha as I initially thought.<\/p>\n<p class=\"wp-block-paragraph\">But is that enough to call it a potential JavaScript replacement? That\u2019s exactly what we\u2019re going to explore today.<\/p>\n<p class=\"wp-block-paragraph\">JavaScript has been the king of web development for decades. It\u2019s everywhere: from simple button clicks to complex web apps like Gmail and Netflix. But now, there\u2019s a challenger stepping into the ring\u2014<strong>PyScript<\/strong>\u2014a framework that lets you run <strong>Python in the browser<\/strong> without needing a backend.Sounds like a dream, right? Let\u2019s break it down in an entertaining <strong>head-to-head battle<\/strong> between these two web technologies to see if PyScript is a true competitor!<\/p>\n<h2 class=\"wp-block-heading\">Round 1: What Are They?<\/h2>\n<p class=\"wp-block-paragraph\">This is like the Jake Paul vs Mike Tyson battle: the new challenger (PyScript) vs the veteran champion (JS). Don\u2019t worry, I\u2019m not saying today\u2019s battle will be a disappointment as well.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s start with the veteran: <strong>JavaScript<\/strong>.<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Created in 1995, JavaScript is the <strong>backbone of web development<\/strong>.<\/li>\n<li class=\"wp-block-list-item\">Runs natively in browsers, controlling everything from user interactions to animations.<\/li>\n<li class=\"wp-block-list-item\">Supported by <strong>React, Vue, Angular<\/strong>, and a massive ecosystem of frameworks.<\/li>\n<li class=\"wp-block-list-item\">Can directly <strong>manipulate the DOM<\/strong>, making web pages dynamic.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">Now onto the novice: <strong>PyScript<\/strong>.<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Built on <strong>Pyodide<\/strong> (a Python-to-WebAssembly project), PyScript lets you write <strong>Python inside an HTML file<\/strong>.<\/li>\n<li class=\"wp-block-list-item\">No need for <strong>backend servers<\/strong>\u2014your Python code runs directly in the browser.<\/li>\n<li class=\"wp-block-list-item\">Can import Python libraries like NumPy, Pandas, and Matplotlib.<\/li>\n<li class=\"wp-block-list-item\">\n<strong>But\u2026<\/strong> it\u2019s still evolving and has limitations.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">This last <em>but<\/em> is a big one, so JavaScript wins the first round!<\/p>\n<h2 class=\"wp-block-heading\">Round 2: Performance Battle<\/h2>\n<p class=\"wp-block-paragraph\">When it comes to speed, JavaScript is like Usain Bolt\u2014optimized and <strong>blazing fast<\/strong>. It runs natively in the browser and is fine-tuned for performance. On the other hand, PyScript runs Python via WebAssembly, which means <strong>extra overhead<\/strong>.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s use a real mini-project: a simple counter app. We\u2019ll build it using both alternatives and see which one performs better.<\/p>\n<h3 class=\"wp-block-heading\">JavaScript<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">&lt;button onclick=\"increment()\"&gt;Click Me&lt;\/button&gt;\n&lt;p id=\"count\"&gt;0&lt;\/p&gt;\n&lt;script&gt;\n  let count = 0;\n  function increment() {\n    count++;\n    document.getElementById(\"count\").innerText = count;\n  }\n&lt;\/script&gt;\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\">PyScript<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">&lt;py-script&gt;\nfrom pyscript import display\ncount = 0\n\ndef increment():\n    global count\n    count += 1\n    display(count, target=\"count\")\n&lt;\/py-script&gt;\n&lt;button py-click=\"increment()\"&gt;Click Me&lt;\/button&gt;\n&lt;p id=\"count\"&gt;0&lt;\/p&gt;<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Putting them to the test:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">JavaScript runs instantly.<\/li>\n<li class=\"wp-block-list-item\">PyScript has a noticeable delay.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">End of round: JS increases its advantage making it 2-0!<\/p>\n<h2 class=\"wp-block-heading\">Round 3: Ease of Use &amp; Readability<\/h2>\n<p class=\"wp-block-paragraph\">Neither of both languages is perfect (for example, neither includes static typing), but their syntax is very different. <strong>JavaScript<\/strong> can be quite messy:<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">const numbers = [1, 2, 3];\nconst doubled = numbers.map(num =&gt; num * 2);<\/code><\/pre>\n<p class=\"wp-block-paragraph\">While <strong>Python<\/strong> is far easier to understand:<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">numbers = [1, 2, 3]\ndoubled = [num * 2 for num in numbers]<\/code><\/pre>\n<p class=\"wp-block-paragraph\">The fact that PyScript lets us use the Python syntax makes it the round winner without a doubt. Even though I\u2019m clearly biased towards Python, the fact that it\u2019s beginner-friendly and usually more concise and simple than JS makes it better in terms of usability.<\/p>\n<p class=\"wp-block-paragraph\">The problem for PyScript is that JavaScript is already deeply integrated into browsers, making it more practical. Despite this, PyScript wins the round making it 2-1.<\/p>\n<p class=\"wp-block-paragraph\">One more round to go\u2026<\/p>\n<h2 class=\"wp-block-heading\">Round 4: Ecosystem &amp; Libraries<\/h2>\n<p class=\"wp-block-paragraph\">JavaScript has countless frameworks like React, Vue, and Angular, making it a powerhouse for building dynamic web applications. Its libraries are specifically optimized for the web, providing tools for everything from UI components to complex animations.<\/p>\n<p class=\"wp-block-paragraph\">On the other hand, PyScript benefits from Python\u2019s vast ecosystem of scientific computing and data science libraries, such as NumPy, Pandas, and Matplotlib. While these tools are excellent for <a href=\"https:\/\/towardsdatascience.com\/tag\/data-visualization\/\" title=\"Data Visualization\">Data Visualization<\/a> and analysis, they aren\u2019t optimized for frontend web development. Additionally, PyScript requires workarounds to interact with the DOM, which JavaScript handles natively and efficiently.<\/p>\n<p class=\"wp-block-paragraph\">While PyScript is an exciting tool for embedding Python into web applications, it\u2019s still in its early stages. <a href=\"https:\/\/towardsdatascience.com\/tag\/javascript\/\" title=\"JavaScript\">JavaScript<\/a> remains the more practical choice for general web development, whereas PyScript shines in scenarios where Python\u2019s computational power is needed within the browser.<\/p>\n<p class=\"wp-block-paragraph\">Here\u2019s a table summarizing some of the key components\u00a0<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"has-fixed-layout\">\n<tbody>\n<tr>\n<td>Feature<\/td>\n<td>JavaScript<\/td>\n<td>PyScript<\/td>\n<\/tr>\n<tr>\n<td>DOM Control<\/td>\n<td>Direct &amp; instant<\/td>\n<td>Requires JavaScript workarounds<\/td>\n<\/tr>\n<tr>\n<td>Performance<\/td>\n<td>Optimized for browsers<\/td>\n<td>WebAssembly overhead<\/td>\n<\/tr>\n<tr>\n<td>Ecosystem<\/td>\n<td>Huge (React, Vue, Angular)<\/td>\n<td>Limited, still growing<\/td>\n<\/tr>\n<tr>\n<td>Libraries<\/td>\n<td>Web-focused (Lodash, D3.js)<\/td>\n<td>Python-focused (NumPy, Pandas)<\/td>\n<\/tr>\n<tr>\n<td>Use Cases<\/td>\n<td>Full web apps<\/td>\n<td>Data-heavy apps, interactive widgets<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p class=\"wp-block-paragraph\">Round\u2019s verdict: JavaScript dominates in general web dev, but <a href=\"https:\/\/towardsdatascience.com\/tag\/pyscript\/\" title=\"Pyscript\">Pyscript<\/a> shines for Python-centric projects.<\/p>\n<h2 class=\"wp-block-heading\">Final Verdict<\/h2>\n<p class=\"wp-block-paragraph\">This was a quick fight! We still don\u2019t know who won though\u2026<\/p>\n<p class=\"wp-block-paragraph\">Time to reveal it:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">If you\u2019re building a full web app,\u00a0 JavaScript is the clear winner.<\/li>\n<li class=\"wp-block-list-item\">If you\u2019re adding Python-powered interactivity (e.g., data visualization), PyScript could be useful.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">With that said, it\u2019s fair to say that <strong>JavaScript (and its derivatives) still remains the web\u2019s frontend best option<\/strong>. However, the future of PyScript is one to watch: If performance improves and it gets better browser integration, PyScript could become a strong hybrid tool for Python developers willing to incorporate more data-related tasks on the frontend.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Winner: JavaScript.<\/strong><\/p>\n<p>The post <a href=\"https:\/\/towardsdatascience.com\/pyscript-vs-javascript-a-battle-of-web-titans\/\">PyScript vs. JavaScript: A Battle of Web Titans<\/a> appeared first on <a href=\"https:\/\/towardsdatascience.com\/\">Towards Data Science<\/a>.<\/p>\n<\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><br \/>\n    Pol Marin<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/towardsdatascience.com\/pyscript-vs-javascript-a-battle-of-web-titans\/\">Go to original source<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PyScript vs. JavaScript: A Battle of Web Titans We\u2019re delving into frontend web development today, and you might be thinking: what does this have to do with Data Science? Why is Towards Data Science publishing a post related to web dev? Well, because data science isn\u2019t only about building powerful models, engaging in advanced analytics, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,83,82,2252,160,2253,2254],"tags":[2256,2257,2255],"class_list":["post-2830","post","type-post","status-publish","format-standard","hentry","category-aimldsaimlds","category-data-science","category-data-visualization","category-javascript","category-programming","category-pyscript","category-web-development","tag-javascript","tag-pyscript","tag-web"],"_links":{"self":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/2830"}],"collection":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/comments?post=2830"}],"version-history":[{"count":0,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/2830\/revisions"}],"wp:attachment":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/media?parent=2830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/categories?post=2830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/tags?post=2830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}