Using the experimental Kotlin Notebook plugin for IntelliJ IDEA, developers will be able to combine code, visualizations, and text, as well as to run code snippets and view their results, all in a single document.
According to JetBrains, the Kotlin Notebook plugin makes it easy to experiment, prototype, and document code.
The Kotlin Notebook plugin brings the power of interactive development to IntelliJ IDEA, supplementing the full power of the IDE’s language support for Kotlin combined with the versatile visualization capabilities of browsers.
A notebook is made of cells, each of which contains either code or text. When you run the code inside a cell, its result is displayed below the cell. Cells can be executed in any order and modified and re-run at any moment, including declaring and re-declaring variables.
The Kotlin Notebook for IntelliJ IDEA supports a number of different output formats, such as simple text, HTML, images, rich text using Markdown, and LaTeX for formulas and equations.
Inside a notebook, you can use any function or type from the standard library. You can also include dependencies from the project the notebook belongs to, as well as specify them in a Maven configuration file or with the DependsOn
annotation. The last two options require knowing the Maven coordinates of the dependency, which can be cumbersome. To avoid this, you can type the %use
command inside a cell to display a list of popular libraries to download and import them according to your requirements.
The Kotlin Notebook also enables extending its functionality through external libraries. For example, an extension library could define code to be run before and after each cell execution, or preprocess a cell's content, customize result display, and so on. This opens up many possibilities to create interactive user experiences, says JetBrains.
As a final note, notebooks can be shared with others. This is possible thanks to the adoption of the Jupyter format, which can be rendered in any notebook web viewer, including GitHub's.
You can install the Kotlin Notebook plugin from JetBrains Marketplace using version 2023.1.2 or newer of IntelliJ IDEA Ultimate.