Creating a Github Pages site blog is all about HTML, CSS, and Javascript – more than I have done lately, anyway. Yes, Github Pages natively supports Jekyll – and I am certainly in the camp that thinks a file-based framework is a fine idea for the vast majority of websites. But, a framework is a framework; there is always a trade-off here and an unexpected price to be paid there when using one. Yes, the good ones all claim to “stay out of your way,” but that is never true until you have hacked and pummelled your way through them and mastered their way of thinking. You can’t do tricks with your instrument of choice until you’ve learned to not trip over it. That truism is part of the motivation for this entry.
I have, of late, thought of myself as a “systems developer” with an emphasis on Python3. I freely confess that my favorite programming language is always the one I’ve used the most in my most recent activities. Several years ago, that would have been Perl, followed by PHP. If you have a sadistic turn of mind and decide to inflict the dread whiteboard coding test on me, it still comes out as Perl. (I am usually effusive in English, impromptu, in front of audiences of more than one; mysteriously, one-on-one interaction is where things begin to go south for me). Anyway, as they like to say in the Perl community: TIMTOWTODI.
That is why I have been excited to find out about Javascript libraries like Skulpt, PyPy.js, Transcrypt, and RapydScript, to name just a few. These are among the most thoroughly developed libraries of their ilk, but there are others out there that do what they do, namely: implement Python2 or Python3 in the browser. They integrate the Python language, in one way or another, with the Javascript engine that is already highly optimized in modern browsers. Of particular interest to me (currently) is the massive Brython library.
Try the Brython console for yourself, below. You can experiment with it directly to discover how much of the full Python3 language is actually implemented. Quite a large number of Python libraries are available for import – not all, of course, but support is very good. Best of all, it makes scripting the browser available to the Python programmer.
Brython, which might be thought of as a “run-time cross-interpreter,” and it’s brethren are certainly not the only examples of this kind of thing. Given the amount of free time that skilled programmers have devoted to develop the next “You-name-a-languange-to-Javascript” transpiler, one would be sorely tempted to conclude that it is the duty of the open-source world to shield the eyes of innocents from the horrors of vanilla Javascript. The sheer number of Coffeescript spin-offs – and all other libraries whose sole purpose is to completely alter its look-n-feel – has to be sending some kind of apocalyptic warning message. There are even collections of tools whose raison d’etra is to help in making the next “Javascript metamorph.” (There is even a Javascript library called “Metamorph”). Perhaps using Javascript to replace Javascript with Python is not the most obvious thing to do, but is, by all reports, surprisingly capable and responsive – and comfortingly familiar to some of us. Kudos to Pierre Quentel and company for Brython, but my admiration extends to the cast of thousands that have made this kind of thing into “a thing.” Is it practical or necessary? I’m not expert enough to boast an opinion. Is it cool? That one’s easy: most definitely.