Announcing Polyglot Notebooks! Multi-language notebooks in Visual Studio Code
We are excited to announce that Polyglot Notebooks, Visual Studio Code’s multi-language notebook extension, is now generally available in the VS Code Marketplace!
Please note: While the Polyglot Notebooks extension in Visual Studio Code is now generally available, the .NET Interactive APIs that power it are still in preview.
What are Notebooks?
If you’re not familiar with notebooks – stop here! A notebook is an interactive programming and computational file that supports mixing executable code, visualizations, equations, and narrative text. Contrary to scripts that need to be run in their entirety, notebooks have code cells that allow code to be run in an incremental and segmented manner. Popularized by the open-source Project Jupyter, you may have heard of these referred to as ‘Jupyter Notebooks’. The component responsible for running code in a notebook is a kernel, and traditionally, Jupyter Notebooks have been most commonly used with Python kernels. Their ability to quickly iterate on code and create visualizations with narrative text have led them to become the de facto tool for data science and great tools for teaching or learning a new programming language, and quick prototyping.
What are Polyglot Notebooks?
Polyglot notebooks elevate notebooks to a whole new level. Polyglot Notebooks’ philosophy is that developers should always be able to choose the best language for the task at hand and today using multiple languages in a traditional notebook is quite cumbersome. You may have a few options through magic commands and wrapper libraries, but both fall victim to a poor editing experience as they lack syntax highlighting, autocompletion and signature help. With Polyglot Notebooks, not only can you use multiple languages natively within the same notebook with full language server support, but you can also share variables between them to maintain a continuous workflow. No need to bounce around from tool to tool and manually transfer data between tools to continue your work.
*It is important to note that Polyglot Notebooks in VS Code are powered by .NET Interactive, which is an innovative engine built using .NET technology that can run multiple languages and share variables between them. Since it is capable of behaving as a kernel in the context of notebooks, .NET Interactive lights up the Polyglot Notebooks experience.
The Polyglot Notebooks extension in VS Code currently supports the following languages with more to come:
- KQL (Kusto Query Language)
*Variable sharing not available
Polyglot Notebook Features
Connect to and query Microsoft SQL Server Databases and Kusto Clusters
Polyglot Notebooks currently has support for connecting to and querying Microsoft SQL Server Databases and Kusto Clusters. After connecting, natively write your SQL or KQL (Kusto Query Language) code to run queries.
Language Server support for all languages
Language server support such as autocompletion, syntax highlighting, and signature help for all languages. Say goodbye to using wrapper libraries when wanting to use multiple languages in the same notebook, and say hello to natively writing code in your preferred language with a first-class editing experience.
To get started you will need the following:
Create your first notebook by opening the command palette (Ctrl+Shift+P in Windows, Cmd+Shift+P on iOS) and selecting “Polyglot Notebook: Create new blank notebook”, select ‘.ipynb’, and select the language you’d like to start with. You should see “.NET Interactive” in the top right as this indicates the kernel being used. To change the language of a cell being used, simply click on the language picker in the bottom right of the cell and choose your desired language. Last but not least, get coding!
We are excited for you to try out Polyglot Notebooks! If you would like to provide any feedback, file any bugs, or request any features, please file an issue on the .NET Interactive GitHub repository. To learn more, visit our Polyglot Notebook Documentation.
Glad to see this hit GA. It has been one of my favourite products from MS for a while now
Apologies that didn’t render!
Are you able to see this on our docs? https://code.visualstudio.com/docs/languages/polyglot#_variable-sharing-and-variable-explorer
I really was surprised how easy it was to extend Polyglot Notebooks with your own language. For these who really wat polyglot experience, and not only based on English keywords you can try https://github.com/kant2002/fsharp-ua-notebook which show you F# in Ukrainian. Truly remarkable how easy it was to extend this product.
I think you probably meant macOS, not iOS? Of course if this works on my iPad, then I’m getting excited!
Are there plans to add additional languages?
Yes, we have plans to add more languages 🙂 Any in particular you were hoping to see? Please file a feature request here: https://github.com/dotnet/interactive/issues
Is it possible to run a notebook file from the CLI (without launching the editor)?