Skip to content

Commit b580155

Browse files
claudiaregioGreg Van Liew
and
Greg Van Liew
authored
add_polyglot_nb_docs (#6060)
* add_polyglot_nb_docs * Update polyglot.md * Update polyglot.md * Update polyglot.md * Update polyglot.md * Update polyglot.md * Edit/formatting pass * Couple more edits * Update polyglot.md * Update TOCTitle, small edits * Small edits --------- Co-authored-by: Greg Van Liew <[email protected]>
1 parent fa35e0c commit b580155

9 files changed

+128
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:30875913bced5e4e7720dac90425521bc02e29c0e873736fe80fd44480c0260b
3+
size 1703901
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

docs/languages/polyglot.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
Order: 20
3+
Area: languages
4+
TOCTitle: Polyglot
5+
ContentId: 4bbd7ad1-8420-4ddd-a86f-442497e597b1
6+
PageTitle: Polyglot Programming with Notebooks in Visual Studio Code
7+
DateApproved: 3/15/2022
8+
MetaDescription: Polyglot Notebooks for multiple programming languages in Visual Studio Code.
9+
---
10+
# Polyglot Notebooks in VS Code
11+
12+
**What is Polyglot Programming?**
13+
14+
Polyglot programming is the practice of using multiple programming languages to leverage the strength of each language for different tasks.
15+
16+
**What are Notebooks?**
17+
18+
Notebooks are interactive files that allow the mixing of executable code, visualizations, equations, and narrative text. Notebooks are composed of code cells that make it easy to quickly iterate on code. Popularized by the open-source project [Jupyter](https://jupyter.org/), they have become the de facto tool for [Python data science](/docs/datascience/overview.md) and a great resource for teaching or learning a new programming language and quick prototyping.
19+
20+
## Polyglot Notebooks
21+
22+
When polyglot programming meets notebooks, you get Polyglot Notebooks! As opposed to traditional notebooks that are typically used with Python, the [Polyglot Notebooks](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) extension allows you to use multiple programming languages natively all in the same notebook in Visual Studio Code! No more needing wrapper libraries or magic commands to work with your favorite languages in the same notebook!
23+
24+
![Polyglot Notebooks Extension](images/polyglot/polyglot_ext.png)
25+
26+
### Languages supported
27+
28+
- C#
29+
- F#
30+
- PowerShell
31+
- JavaScript
32+
- HTML
33+
- Mermaid
34+
- SQL
35+
- KQL (Kusto Query Language)
36+
37+
## Features
38+
39+
In addition to executing the code for the languages above, you can take advantage of:
40+
41+
- **Connecting to and querying from** Microsoft SQL Server databases and Kusto clusters.
42+
43+
- **Language server support** such as IntelliSense, autocompletion, and syntax highlighting _for each language_.
44+
45+
- **Variable sharing** between languages that ensures a continuous workflow within the notebook. (Variable sharing not available for HTML and Mermaid)
46+
47+
- **Variable Explorer** to check state of variables and the subkernel variables exist in.
48+
49+
- **Full portability between Jupyter/JupyterLab**.
50+
51+
To learn about all the features, visit the VS Code Marketplace [Polyglot Notebooks](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) extension.
52+
53+
## Prerequisites
54+
55+
To use Polyglot Notebooks in VS Code, you will need:
56+
57+
- [Polyglot Notebooks](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) extension
58+
- [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
59+
60+
### Why do I need the .NET SDK?
61+
62+
The Polyglot Notebooks extension is powered by .NET Interactive, which is a cutting edge and innovative engine built on .NET technology that can run multiple languages and share variables between them. In Polyglot Notebooks, this engine behaves as the notebook's kernel and is the reason that the .NET 7 SDK is required.
63+
64+
## Getting started
65+
66+
1. To create your first polyglot notebook, open the Command Palette (`kb(workbench.action.showCommands)`) and select **Polyglot Notebooks: Create new blank notebook**, select `.ipynb`, and select the language you'd like to start with.
67+
68+
You can also create a notebook by creating a new file and giving it the extension `.ipynb`. In this case, make sure that **.NET Interactive** is selected as the kernel of the notebook in the top right.
69+
70+
![Kernel Picker](images/polyglot/kernel_picker.png)
71+
72+
2. By default, added cells will be the same language as the cell above it. To change the language, select the language picker in the bottom right of the cell.
73+
74+
![Cell Language Picker](images/polyglot/language_picker.png)
75+
76+
3. Get coding!
77+
78+
![Example of Polyglot Notebook](images/polyglot/polyglot_nb_example.png)
79+
80+
## Working with data
81+
82+
Connect to and query Microsoft SQL Server databases and Kusto clusters.
83+
84+
To get more detailed instructions on connecting to and working with data sources, visit the [Working with Data](https://github.com/dotnet/interactive/blob/main/docs/working-with-data.md) documentation.
85+
86+
![Connecting to SQL Example](images/polyglot/SQL_connection_example.png)
87+
88+
## Language server support
89+
90+
Each language in Polyglot Notebooks gets a first-class editing experience with language server support such as autocompletion, syntax highlighting, and signature help.
91+
92+
## Variable Sharing and Variable Explorer
93+
94+
Share variables between languages using the `#!set` command and check on the values of variables for each language using the Variable explorer. Note that if you were previously using the `#!share` command, it will continue to work. Select the **Variables** icon in the global toolbar to open the Variable explorer.
95+
96+
<video src="images/polyglot/SQLJavaScript.mp4" placeholder="images/polyglot/SQLJavaScript.mp4" autoplay loop controls muted title="Video showing user sharing variables between SQL and JavaScript">
97+
Sorry, your browser doesn't support HTML 5 video.
98+
</video>
99+
100+
To learn more about variable sharing, visit the [Variable Sharing](https://github.com/dotnet/interactive/blob/main/docs/variable-sharing.md) documentation.
101+
102+
## Feature requests and feedback
103+
104+
The Polyglot Notebooks extension is powered by .NET Interactive and you can provide feedback and enter issues on the [.NET Interactive GitHub repository](https://github.com/dotnet/interactive/issues).

0 commit comments

Comments
 (0)