Aucune description alternative pour cette image

JavaScript and its vast ecosystem (React, Angular, Vue.js, etc.) have dominated client-side Web programming for several years now, despite all the criticisms that can be leveled at them. However, other languages such as Go and C are trying to do the same. Brython, an implementation of Python 3, is also trying to replace JavaScript in client-side Web programming. Brython allows you to write Web applications in Python instead of JavaScript, by inserting Python 3 code directly into an HTML page. The question is whether it will succeed in dethroning JavaScript.

Brython, for Browser Python, is a browser-based implementation of Python 3 with an interface to the DOM elements and events. In other words, the Brython tool supports the syntax of Python 3, including understandings, generators, metaclasses, imports, etc., and many modules of the CPython distribution. It includes libraries for interacting with elements and events in the DOM and with existing JavaScript libraries such as jQuery, 3D, Highcharts, Raphael, etc.

In addition, it supports the latest HTML5/CSS3 specifications, and can use CSS frameworks such as Bootstrap3, LESS… According to its developers, Brython was developed to replace JavaScript as a scripting language for Web browsers. According to their explanations, the execution speed of Brython is similar to that of the CPython interpreter for most use cases. Their site explains some of the possibilities it offers, from the creation of simple document elements to drag and drop and 3D navigation.

HTML Code:

1 <html>   
2         <head>
3             <script type="text/javascript" src="/path/to/brython.js"></script>
4         </head>
5         <body onload="brython()">
7             <script type="text/python">
8             from browser import document, alert
10            def echo(event):
11                alert(document["zone"].value)
12            document["mybutton"].bind("click", echo)
13            </script>
15            <input id="zone"><button id="mybutton">click !</button>
17        </body>
18  </html>


In Brython, the output can be done in different ways, notably with the alert() function (also defined in the browser) which displays a popup window with the text passed as argument. However, if Brython can be just as useful as JavaScript, will it steal the show from client-side Web programming? Will developers familiar with the JavaScript ecosystem want to use this new tool? Many people think not, citing the long road JavaScript has traveled so far.

For example, according to the State of JS 2019 report by Sacha Greif and Raphaël Benitte, some 11 million developers around the world would use JavaScript. The report showed that, whether we like it or hate it, the language continues to gain ground and its ecosystem continues to grow. It is essential to modern development and has been the first programming language on GitHub since 2014. The Python language is in second place in this ranking, ahead of Java, which is in third place.

On the other hand, other programmers feel that JavaScript has come a long way and, despite its inherited quirks, it is actually very nice with ECMAScript 6 (ES6). In addition, its ecosystem contains many tools to enhance the Web development experience. According to them, although it would be better to use a language that doesn’t need 3 signs of equality to make healthy comparisons, Python, with its strong correlation between white spaces and blocks of code, is a good choice for remote transmission and execution.

Some Python developers have answered no to this question. They believe that JS objects are one of the most beautiful things in the language. On the other hand, according to them, Python objects are still opaque to many Python developers. They also added that many things supported by Python objects such as inheritance seem openly undesirable, and the metatype system seems much more complicated than it should be (partly because inheritance confuses things). Would you use Brython instead of JavaScript for client-side Web programming?

Sources : BrythonPage GitHub de Brython

July the 7th 2020 16:47, by Bill Fassinou

And you?

 What do you think of Brython?

Do you think it will be able to steal the show from JavaScript for client-side Web programming?

Will developers familiar with the JavaScript ecosystem want to part with it for a new tool?

Articles Similaires

OUIcoding facilite, permet, promeut et célèbre l’innovation !


Nous suivre

Email: [email protected]
Tél: +33 1 84 19 03 47 
Tél: +33 6 58 26 23 59