Skip to content

Proposal: A Different Extension Model #216

@stianhoiland

Description

@stianhoiland

re: #17

Aka. "It's tempting to live in your editor, but have you tried living in your shell?"

Recently I dove deep into and embraced working on the command line--yes I know, I know, I'm late--and consequently I've experienced insights and dramatic changes to my notions of HCI and productivity. Like many, much of my usage of the command line revolves around the text editor, but I think my experience is different from most and worth reflecting on. The difference lies in the approach to building productivity by complimenting and extending tools. In the following I don't intend to make any claims to originality, only to cast light on, after having discovered for myself, the ways of the Old Ones.

I wouldn't bother you with this proposal if I didn't think that this project could potentially affect many people for a long time, nor if I didn't think that the alternative extension model I want to propose is substantially more useful and sustainable.

After my personal "zero to hero" on the command line, I now think that all productive development environments require scripting with an interpreted language and that the significance of this is both completely misunderstood and taken for granted. The common way to implement this is by embedding an interpreter and exposing key infrastructure in the host software, and thus allow the user to extend and modify its usage by writing scripts in the chosen interpreted language targeting the exposed API. The software itself hosts and owns the interpreter instance, and thus the extension mechanism.

Vim with VimScript, Emacs with Emacs Lisp, Neovim with Lua, and other software using Python, Ruby, JavaScript and in-house abominations.

These days this model and its compiled plugin counterpart are taken for granted, and I think the reason is GUI.

What unites programs in the GUI paradigm is the presentation of their output inside rectangles, input captured by interaction within those rectangles, and the manipulation of the display of those rectangles. That's the interaction platform of the GUI, and within this environment the GUI hosts its denizens and, let me say it again, unites them in being interactable rectangles.

What unites the programs in a GUI and underlies that platform is not scriptability, but graphical interaction, and therefore scriptability must be the concern of each program individually. The programs are not hosted within an environment that already provides a platform for interpreted programming/scripting, the capabilities of which they could have passively consumed. Instead, they are hosted within an environment that already provides graphical interaction, the capabilities of which they passively consume. The GUI is not founded on programmability/scriptability.

Enter the command line shell.

The shell is fundamentally and natively an interpreted environment. This is hard to overstate. From the bottom to the top the shell exists as an interpreter, within which it hosts its denizens. Whether writing singular command lines on the prompt or arbitrarily assembling command lines in files to be read and interpreted sequentially, the shell is programmability. As such there is no need for command line programs to concern themselves with hosting their own scriptability--this is already provided natively by their host environment. (Although of course they can, as we'll later understand, there is no reason to host their own.)

In fact, much can come from command line programs deriving their scriptability from the shell's hosted scripting environment rather than from their own isolated private scripting silos. Much like how GUIs provide a unified elegant graphical interaction paradigm, shells provide a unified elegant scripting/programmability paradigm. (Recall my conviction that all productive development environments nontrivially and unobviously require scripting.)

The extension model here is very different. Rather than exposing its infrastructure inwardly and hosting scripts that access its API, to be composed with and extended by other denizens of the shell's provided native programming environment, programs must instead expose themselves to the host environment, providing/serving their essential state and data in an easily digestible manner.

This is a model that favors "small" programs. If your program's data and state is huge and complex then serving it performantly and meaningfully becomes hard. I challenge you to think of a text editor in an almost Platonic way: What is essential to a text editor? What is the essential, nonreducible state and data that describes a text editor and nothing else? This and only this is what should be exposed to the other denizens of the shell. Anything else they could by definition gather or derive from elsewhere. To close out this thought: There is not only beauty in small programs--of which Edit could be one--but the size of programs is self-fulfilling. When your programs become big, they need to become bigger; and when your programs are small, they stay small. This is because big programs do not delegate their concerns to other programs, while small programs do.

An example of what much can come of a (small) program deriving its scriptability from the shell is that by having access to the program's essential state through the shell, a user can install any standalone interpreter, like Lua, Python, Ruby, PHP, etc., and write their extensions and scripts in whatever language they want, in effect extending the program's scriptability to support any scripting language the user fancies, today and in the future. Indeed, enabling the user to use any extension method.

The shell already provides a scriptable, interpreted environment, replete with a language specialized for composing programs--like say, Edit and whatever programs that do whatever you want to extend Edit with. And do not underestimate the utility of being able to slap together a cmd/PowerShell/Bash script to extend your text editor--I could write a whole 'nother one of these on that topic. You don't need to ship Lua. Not only do you already have an interpreted language--a TUI text editor necessarily runs in a shell--you also get an impressively more powerful extension model by architecting for its use. With there conceivably never being a time when Edit no longer use the console subsystem, there is no reason for Edit to start off on the wrong foot and pretend to be a GUI program (in this technical sense) that needs its own scripting silo.

Before this gets any longer, I will end it, though with more to say!

For empowering users now and in the future, I hope this proposal will be considered.

Relevant: #89, #90 (and others I might collect later)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions