Pagebreaks: Multi-Cell Scopes in Computational Notebooks
Honorable MentionResearch Background and Problem
-
Problems or Challenges Identified by the Authors:
Programmers often encounter confusion when using Jupyter Notebook due to the extensive use of global variables, such as the need to track variables, avoid overwriting commonly used variables, and understand execution order. This reliance on global state can lead to difficulties in understanding, debugging, and organizing code. Additionally, users in the Notebook programming environment tend to use function scopes less frequently, partly because functions cannot span multiple cells and they limit interactivity and exploratory programming behaviors. -
Why This Problem Is Important:
As a mainstream tool for data science and exploratory programming, Notebook programming faces the dual challenge of simplifying code management while maintaining high interactivity. If these issues are not addressed, developing large-scale Notebook projects may become a complex and error-prone task. Moreover, the difficulty of managing global variables can negatively impact collaboration and reproducibility of results. -
Research Motivation and Related Work:
Existing research has found that Notebook users tend to avoid organizing code within functions, instead sharing state through global variables. This practice can lead to chaotic execution states, especially as Notebooks grow more complex. Furthermore, the Notebook programming environment emphasizes exploratory workflows, such as building code across multiple cells and interactively adjusting its effects. However, the function scope in traditional programming is incompatible with these exploratory behaviors.
Solution
-
Proposed Solution by the Authors:
The authors designed a new language construct called "Pagebreaks," which allows users to create non-global scopes across multiple cells in Jupyter Notebook. Pagebreaks restrict the variables of certain cells to their defined scope but allow explicit exporting of variables for use in subsequent cells. Compared to functions, Pagebreaks preserve the exploratory behaviors of users in the Notebook environment. -
Innovative Aspects of the Solution:
- Pagebreaks provide non-global scopes without disrupting the exploratory workflow of Notebooks (e.g., alternating versions, interleaving code and outputs, etc.).
- They allow scope to span multiple consecutive cells rather than being limited to a single function's scope.
- The variable export mechanism specifically addresses the issue of variable redefinition, making variables read-only outside their scope, thus reducing conflicts and confusion.
- The design is closely aligned with Notebook user behaviors, such as linear organization of scopes, to preserve the unique advantages of the Notebook's execution order.
-
Implementation Steps and Techniques:
- Design Requirements: Retain the exploratory workflow of Notebook users while providing better variable management.
- System Implementation: Pagebreaks were implemented as a plugin for Jupyter and IPython, modifying the program's Abstract Syntax Tree (AST) to add unique prefixes to each Pagebreak to manage their scope.
- Operational Mechanism: Users mark Pagebreaks through the interface, allowing variables to be freely used within the scope but requiring explicit export for subsequent cells to access them.
- Visualization Features: Background colors, visual hierarchies, and graphical interface elements like buttons are provided to help users organize their programs.
Research Outcomes
-
Specific Outcomes:
- Developed the "Pagebreaks" plugin to create scopes across multiple cells in the Notebook environment.
- Conducted a two-week user study observing five participants using Pagebreaks and the problems it addressed.
- Found that Pagebreaks improved users' ability to organize and manage Notebook programs without interfering with their existing exploratory behaviors.
-
Advantages Compared to Existing Solutions:
- Solves the challenge of managing global variables while retaining Notebook interactivity.
- Provides a more flexible cell organization model than function scopes, enabling cross-cell variable sharing.
- Supports improved debugging processes in Notebooks, helping isolate issues without disrupting the current program state.
-
Experimental or Evaluation Results:
Participants noted that Pagebreaks helped track variables and reduce naming conflicts while aiding in code segmentation and file organization. The study found that Pagebreaks naturally extended Notebook user behaviors, addressing variable confusion without sacrificing familiar interactivity. -
Limitations and Future Directions:
- The study involved a small number of participants and limited usage duration, leaving broader Notebook programming behaviors unexplored.
- Pagebreaks currently do not support user customization of colors and style settings.
- Future directions include adding features like highlighting exported variables and expanding the application scope of Pagebreaks.
- Subsequent research could explore the long-term impact of Pagebreaks on Notebook programming behaviors and how to further simplify its usage process.
Through this research, the authors effectively demonstrate how to design novel language features for Notebook programming that integrate user, language, and environment needs while preserving the flexibility of exploratory workflows. This provides an important reference for designing targeted programming environments in the future.
Research Questions / Practical Problems
Question signals indexed for this paper.
Research Questions
3- How can variable management, debugging, and organization difficulties caused by heavy global variable use in Jupyter Notebook be alleviated?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- What approaches can introduce non-global variable scoping without breaking exploratory programming in Notebooks?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- Can a 'Pagebreaks' design improve users' ability to manage code and variables in Notebooks?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
Practical Problems
1- Programmers in Notebooks struggle to track variables and avoid naming conflicts due to global variable effects.Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- 100%
Using Annotations for Sensemaking About Code
UIST '22· Knowledge Worker Tools & Workflows +1
- 100%
Lorgnette: Creating Malleable Code Projections
UIST '23· Knowledge Worker Tools & Workflows +1
- 75%
Computational Interaction: Theory and Practice
CHI '18· Computational Methods in HCI
- 75%
Model-based Evaluation of Recall-based Interaction Techniques
CHI '24· Computational Methods in HCI
- 75%
Small-Step Live Programming by Example
UIST '20· Computational Methods in HCI
- 60%
Visualizing API Usage Examples at Scale
CHI '18· Interactive Data Visualization +1
- 60%
Doppio: Tracking UI Flows and Code Changes for App Development
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Pointing All Around You: Selection Performance of Mouse and Ray-Cast Pointing in Full-Coverage Displays
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Observations on Typing from 136 Million Keystrokes
CHI '18· User Research Methods (Interviews, Surveys, Observation) +1
- 60%
Interactive Extraction of Examples from Existing Code
CHI '18· Open-Source Collaboration & Code Review +1
Based on Jaccard similarity of research subtopics & professions (≥60%)