Python in the Browser

Feature image: 

Given the increasing difficulties in using Java applets in the web browser, an appealing alternative would be to simply use Javascript to run Python scripts and programs in the user's web browser. Here's a blog entry from "0xdabbad00" (Scott Piper) that describes the different options pretty completely. I've spent a bit of time messing with the PythonJS approach of "cross-compiling" Python scripts to Javascript, and like the aforementioned blogger I ended up moving on to Skulpt to try and run Python scripts directly in the browser instead.
Quite a bit of work has been accomplished with Skulpt so far. One of the more interesting products is called Trinket, which is an interactive Python interpreter that runs in your browser. Using Trinket you can write Python scripts, run them, store and share them - all right on their site. They have also contributed code to the general Skulpt project that expands the Python libraries that are available.
Skulpt has been pretty powerful, although a serious shortcoming is the complete lack of any user documentation on how to take advantage of any features beyond the couple of examples given on the home page of their website. They do offer extensive documentation for developers who want to contribute new code to the project, just not anything for people who want to use the existing code. Nonetheless, I've been able to put together an example page that uses Skulpt to explore the waveforms generated by a switching-type mixer. Essentially, the Python script is stored in the HTML of the web page and then handed off to the Skulpt Python interpreter via Javascript when the "run" button is pressed by the user. This will enable much more rapid development of calculators for this site!

Category: