Structured Editing for All: Deriving Usable Structured Editors From Grammars
Authors
Title of the Paper
Structured Editing for All: Deriving Usable Structured Editors from Grammars
Paper Information
- Domain: Software Engineering, Design of Programming Language Editing Tools
- Keywords: Structured editing, grammar, text-like editing, user study, Clojure, JavaScript, regular expressions, Tree-sitter, automatic generation, input reconciliation
- Conference: CHI 2023
- Authors: Tom Beckmann, Patrick Rein, Stefan Ramson, Joana Bergsiek, Robert Hirschfeld
- Affiliation: Hasso Plattner Institute, University of Potsdam, Germany
Research Background and Problem Statement
-
Identified Problems:
- Structured editors provide significant benefits in programming tools, such as improved learnability, editing efficiency, and tool integration. However, developing general-purpose and usable structured editors is costly and complex, with existing work often requiring custom interaction designs for each language.
- Some automatically generated editors lack interactivity and offer an editing experience less natural than traditional text editors, particularly for complex programming languages like Rust and TypeScript.
-
Significance:
- Structured editors can consistently maintain program syntax validity, offer syntax guidance, simplify the development of combined languages, and support innovative tool integration.
- Combining the fluid input advantages of text editors can significantly lower the barrier to entry, enabling developers of various languages to use structured editors.
-
Motivation and Related Work:
- Existing tools face significant trade-offs between editor usability and language compatibility (Usability vs. Availability).
- Previous work has demonstrated some effective structured editors, such as Lamdu and GrammarCells, but these are often not extensible to general-purpose languages or require extensive manual annotations of grammar.
- The authors propose leveraging language grammar engines (e.g., Tree-sitter) to automatically derive general editing operations, aiming for a consistent user experience.
Solution
-
Proposed Method or Solution:
- A system named Sandblocks is introduced, which automatically generates fluid structured editors from arbitrary grammars (e.g., Tree-sitter grammar format).
- A novel input reconciliation process is designed to map user keyboard inputs to syntax trees in real-time, generating corresponding interface interactions.
-
Innovations:
- Proposes an editing generation process that does not require manual grammar annotations, allowing real-time reconciliation with syntax trees to create intuitive structures during user input.
- Supports flexible, text-like editing operations without losing traditional advantages such as automatic syntax validation.
-
Implementation Steps and Key Techniques:
- Grammar Import: Extract and refine rules from Tree-sitter grammars, converting them into editable UI data structures.
- Input Reconciliation: Dynamically map user text operations into syntax-driven input logic based on three key design principles:
- Navigation follows the visual layout of the text interface.
- Character input behaves like text manipulation, buffered until fully parsed.
- Deletion operations adopt minimally disruptive methods, explicitly capturing context.
- Interface Generation and Interactive Design: Generate an editing interface organized around block-level syntax tree elements, supporting insertion pop-ups and real-time error mechanisms.
Research Outcomes
-
Key Results:
- Developed the open-source tool Sandblocks, which successfully auto-generates structured editors for multiple common languages (e.g., JavaScript, Clojure, Python, TypeScript).
- The proposed editing model ensures compatibility with new languages and provides consistent interaction behavior.
-
Advantages over Existing Solutions:
- Compared to tools that only support domain-specific languages, Sandblocks offers higher generality.
- User studies indicate the system has a low learning curve, with user experience close to that of text editors.
-
Experiments and Evaluation Results:
- User Experience:
- Conducted a user study (N=18), with participants rating the naturalness of the editing experience at 6/7 (median score), though deletion and navigation received slightly lower scores.
- Minimal differences in cognitive load compared to traditional text editors (measured using the NASA TLX scale).
- Learning Transferability:
- A tutorial based on a single language (Python) enabled users to successfully complete tasks in other languages (e.g., JavaScript, Clojure, and Regex), demonstrating cross-language consistency.
- Editing Efficiency:
- Overall, editing was 20%-95% slower than in text editors. Efficiency losses were more pronounced for Regex tasks, while JavaScript and Clojure tasks showed only a 1.2-1.3x slowdown.
- Program Reproduction Capability:
- Successfully re-entered 250 open-source project syntax targets with a 96% accuracy rate. Failures were primarily due to specific syntax features like template strings.
- User Experience:
-
Limitations and Future Directions:
- Limitations:
- The pop-up mechanism for resolving input ambiguities confused some users.
- High padding and uneven layout increased the learning curve for navigation operations.
- While advertised as "supporting any grammar," customized characters (e.g., omitted commas) led to varying user perceptions and errors.
- Future Directions:
- Improve error recovery mechanisms to reduce large-scale rollback operations.
- Optimize interactive editing experiences, such as cursor movement, and enhance alignment strategies for large nested blocks.
- Explore integration of pop-ups into tree structures to further validate seamless transitions in editing.
- Limitations:
Research Questions / Practical Problems
Question signals indexed for this paper.
Research Questions
3- How can fluent structured editors be automatically generated from arbitrary grammar rules?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- When mapping users' keystrokes to syntax trees in real time, how should interaction be designed to ensure a natural editing experience?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- Can automatically generated structured editors compete with traditional text editors in grammar compatibility and user friendliness?Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
Practical Problems
1- Programmers often abandon structured editors due to unnatural interaction or poor language compatibility.Category: Coding Assistants and Multi-Turn Code SupportSimilar questionsarrow_forward
- 67%
Colaroid: A Literate Programming Approach for Authoring Explorable Multi-Stage Tutorials
CHI '23· Programming Education & Computational Thinking +2
- 60%
Challenges and Opportunities for Technology-Supported Activity Reporting in the Workplace
CHI '18· Knowledge Management & Team Awareness +1
- 60%
ActiveErgo: Automatic and Personalized Ergonomics using Self-actuating Furniture
CHI '18· Full-Body Interaction & Embodied Input +1
- 60%
Exploring New File Metaphors for a Networked World through the File Biography
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Doppio: Tracking UI Flows and Code Changes for App Development
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Pointing at a Distance with Everyday Smart Devices
CHI '18· Full-Body Interaction & Embodied Input +1
- 60%
Using Visual Histories to Reconstruct the Mental Context of Suspended Activities
CHI '18· Knowledge Worker Tools & Workflows +1
- 60%
Leveraging Community-Generated Videos and Command Logs to Classify and Recommend Software Workflows
CHI '18· Crowdsourcing Task Design & Quality Control +1
- 60%
HotStrokes: Word-Gesture Shortcuts on a Trackpad
CHI '19· Hand Gesture Recognition +1
- 60%
GazeConduits: Calibration-Free Cross-Device Collaboration through Gaze and Touch
CHI '20· Eye Tracking & Gaze Interaction +1
Based on Jaccard similarity of research subtopics & professions (≥60%)