News

VS Code Preview: Python in the Browser, Executed by WebAssembly

In the December update to Python in Visual Studio Code, developers can experiment with a new preview feature that lets them run and debug Python code in the browser.

The team develops the Python extension in the VS Code Marketplace, which also automatically installs the associated Jupyter extension and the Pylance language server, for providing Python-specfic "smarts" like auto-completion and so on. Those three tools are by far and away the most popular items in the VS Code Marketplace, with more than 72 million installs for the main tool, 53 million installs for the Jupyter tool and 45 million for Pylance.

In the new update, the preview experiment for browser-based Python coding works only with the browser-based implementation of VS Code, accessed at https://vscode.dev/. To do so, it relies upon WebAssembly, the open source tech that makes Blazor possible by letting developers use C# instead of JavaScript. Specifically, it provides a portable compilation target for C# code in client-side Blazor WebAssembly.

However, the experiment isn't ready for prime time, nor is it clear if it ever will be.

"There's a new VS Code extension that allows you to try running Python code in the Web using WebAssembly as an execution engine," the dev team said in announcing what's new in the latest monthly update. "Please note that this extension is being used for experimental and research purposes to gain an understanding of running Python code in the Web using WebAssembly and should not be used for production Python development as there are significant limitations."

What's more, developers have to jump through several hoops -- eight in all -- to get it working (this reporter couldn't even get it to work even following instructions explicity).

[Click on image for larger view.]

Even so, the Experimental - Python for the Web (Preview) extension in the VS Code Marketplace has been installed 283 times as of this writing (see screenshot above). The item description lists the experiment's limitations:

  • Python interpreter limitations
    • no pip support.
    • no socket support.
    • no support for native Python modules.
    • no thread support. As a consequence there is no async support either.
  • VS Code limitations
    • no debug support. You can only run a Python file.

New functionality that can be used in production includes improvements to auto indentation in Pylance.

"The Pylance extension for VS Code is working to improve our auto indent feature through its deeper understanding of Python!" the team said. "This feature allows you to focus more on the logic of your code and less on formatting. Try it out in VS Code Insiders using the Pre-Release version of the Python extension!"

Several other enhancements and fixes were detailed in the announcement post and can be explored further in the changelogs for Python, Jupyter and Pylance.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube