Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An idea for a modern editor

The modern editor

An idea to change the way we interact with files in 2013 and beyond.

At the beginning of the Internets, there was HTML.

Using a limited set of tags, people were able to create webpages by assembling the bricks using, let's be honest, a shitload of tables for layout purposes.

Though looking back on it now seems like the dark ages (and is nowadays loudly frowned upon), it didn't prevent a whole new world from being created.

The advent of CSS and Javascript has now changed that for the better (mostly). We now understand that content is separate from its representation.

Developers are thus diligent about separating their markup and their stylesheets. And nothing prevents me from taking a webpage on some website, applying a custom stylesheet and consuming the content the way I want.

As basic as those concepts have become, there is still a domain where progress is still extremely slow and where the aforementioned now commonly accepted concepts are foreign: EDITORS. The same recipes are being applied over and over again, and save for some graphical refreshing brought by the New Kid On The Block ™ (think SublimeText, TextMate, Chocolat and all those fancy-pants graphical editor that bring nothing but a handful of smart-aleck keyboard shortcuts to the same ol' same ol').

For some reason, the file that I see when I look at my editor is still a perfect 1-1 mapping for the bits stored on the disk. It's still the same series of bytes that I will send on the wire when I finally decide to push that code on some remote repository. It's still the same arrangement of symbols a bunch of colleagues have potentially messed with to my utter dismay.

Things you might have thought or overheard at work

" Ain't that the worst, what kind of moron uses 8-space indentation???? :/ "

" I hate it when the parens are on the same line… "

" Dammit, too much commenting is WORSE than no commenting, where's the code? "

" That commit message has the WORST formatting ever, FUCK THIS SHIT"

In an ideal world, none of the aforementioned quotes would even be relevant. I see no reason why you would have to suffer because some indentation is not right or because the code is littered with superfluous and non-sensical notes, fixmes and comments.

How to remedy the issue

I think a good way to solve most of those issues and usher a new era in the way we produce the code who earns us a living is to apply the same sane principles that our brains puts at work when it makes us appreciate sounds or images, taste flavours and so on: apply transformations. Programmers are supposed to be good at that. That's our thing.

So what kind of transformation are we talking about here?


The representation (i.e. the content)

The editor doesn't store the file itself. Instead it stores some AST-like representation of the source code. Something like XML, JSON, whatever neutral, non-opinionated and easily-diffable representation of a tree you can think of. That's the content. That's what git cares about. That's what you share with your colleagues.

The transformation (i.e. a function)

This representation then goes through a transformation (think of the eardrum applying a transformation of the sound wave and transmitting it to the brain for processing). This transformation is defined through a series of user-defined "stylesheets". Those stylesheets define all the graphical fine-tuning that a user might want to apply to the "AST" such as:

  • Transform {} into do…end when relevant and add a newline
  • Add two linefeeds between each method
  • Display all the comments I marked as @personal in the previous commit and who were as such never added to the AST-like representation.
  • no-comments, remove all comments from other developers (this is a toggle that can be activated by context, be it for the whole file, a method, a block, a line, etc.)
  • Indent everything with one soft tab

i.e. make that representation look how I want it to look like, not some watered-down, soft style that satisfies no one but doesn't rub anyone the wrong way either.

The coding (i.e. a better experience)

Your code looks awesome. No one ever complains about differences in subjective opinions, the representation backing the file is easier to diff (not so sure about that one, but I guess). Hell you can even have => being replaced by → if you want to, you're the bawss.

The issues

"But how are we supposed to interact with other editors"

Frankly, I don't know. Either we have some gofmt-style kind of tool per language to produce a commonly accepted style guide per file when interfacing with other people or each editor implements an interface to that system. I mostly don't care anyway, I know for a fact that the system will most likely never change and just wanted to get those thoughts in writing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.