Edit code as code

Shahar Or (mightyiam)
2 min readMar 10, 2021

Save programmatic code manipulation, the only way I’ve ever seen software developers edit code, is by treating it as text.

Our skills in editing text do carry on from one programming language to the next. Also, as a programming language evolves new syntax, code editors don’t necessarily have to gain awareness of it — they are already able to write any new syntax. Yes, editing text as code is versatile. We’ve been doing this for more than 50 years. Modern text editors are aware of programming languages and provide features that enhance our productivity: auto-completion and refactoring abilities help me a lot. Yet, could there be a more intuitive and natural way to edit code?

What if we write and edit code using a comprehensive set of primitive mutations?

Imagine an editor that does not allow you to just edit text. You do see the code just as you are used to seeing it — a matrix of lines and columns with mono-spaced font characters filling the cells. But you’re not be able to edit characters freely. Instead, to make any edit, you issue a command that describes a mutation. Commands could be specified in numerous configurable ways. They could be typed in, executed via custom keyboard shortcuts, selected using a pointing device and even spoken and taken as speech recognized audio input.

Will it be faster?

A user who went the length to make themselves familiar with the commands available for editing a particular language, and have developed their own editing style, which consists of custom keyboard shortcuts and editor preferences, etc., in my imagination would edit code faster than they currently is able to edit it as text.

How many will invest the time and effort it takes to learn this new way of editing code?

Developers are investing considerable time and effort mastering keyboard-intensive editors such as vi and Emacs. Some have changed the layouts of their keyboards from whatever they are used to, into the more optimized Dvorak keyboard layout. If we learn of a new way to edit code that is demonstrably faster, then I expect some of us attempt to adopt it.

Could refraining from editing text reduce mental load?

When we edit code as text, we must be acutely aware of the programming language’s syntax. And while editing we frequently toggle the code between valid and invalid syntactical states. Editing code as code refrains from this, as the code remains in constant syntactical correctness. Would this lift a burden off of our mental “shoulders”?

What’s next?

Please star this repository to show your interest and subscribe to this thread for further announcements (super low volume).

I’d like to help build this thing

I sure need some help with this. Contact me.

--

--