Charles Explorer logo
🇨🇿

Interaction vs. Abstraction: Managed Copy and Paste

Publikace na Matematicko-fyzikální fakulta |
2022

Tento text není v aktuálním jazyce dostupný. Zobrazuje se verze "en".Abstrakt

Abstraction is at the core of programming, but it has a cost. We exhort programmers to use proper abstractions like functions but they often find it easier to copy & paste instead.

Copy & paste is roundly criticized because subsequent changes to copies may have to be manually reconciled, which is easily overlooked and easily mistaken. It seems there is a conflict between the generality and reusability of abstraction with the simplicity of copying and modifying code.

We suggest that this conflict arises because we are still thinking in terms of paper-based notations. Indeed the term "copy & paste"originates from the practice of physically cutting and gluing slips of paper.

But an interactive programming environment can free us from the limitations of paper. We propose managed copy & paste, in which the programming environment records copy & paste operations, along with structural edit operations, so that it can track the differences between copies and reconcile them on command.

These capabilities mitigate the aforementioned problems of copy & paste, allowing abstraction to be deferred or reduced. Managed copy & paste resembles version control as in git, except that it works not between versions of a program but between copies within the program.

It is based on a new theory of structural editing and version control that offers precise differencing based on edit history rather than the heuristic differencing of textual version control. We informally explain this theory and demonstrate a prototype implementation of a data science notebook.

Lastly, we suggest further mechanisms of gradual abstraction that could be provided by the programming environment to lessen the cognitive load of programming.