Sharing Variables between Languages with Polyglot Notebooks

Showing the process of sharing data between C# and F# Notebook Cells

Matt Eland
AccessibleAI

--

While Polyglot Notebooks certainly brings the dream of notebook development to dotnet, Polyglot is at its finest when you work with one language and then hand off data to the next language for additional processing.

In this article we’ll talk about sharing variables between kernels using Polyglot Notebooks and VS Code. We’ll explore the syntax and tooling that exists around these functionalities as well as the current limitation of sharing variables between kernels.

For simplicity, I’m going to avoid getting into SQL and KQL kernels in this article, but I plan on delving further into each of these specialized kernels in future articles.

Understanding Variables and Kernels

As I’ve noted before, Polyglot Notebooks are powered by the .NET Interactive kernel, which is actually an amalgam of a number of different language-specific kernels such as the C# kernel and the F# kernel all operating under a larger umbrella.

This means that variables you define in C# will not be immediately available in F# (and vice versal).

--

--

Matt Eland
AccessibleAI

Microsoft MVP in AI, AI Specialist at Leading EDJE. Author of "Refactoring with C#".