The code formatting fallacy

Time to stir my category cloud on the right a bit, and publish a post under a category I’ve so far only used once. Hopefully it will become clear what Language Oriented Programming (LOP) has got to do with code formatting after this post.

There are several holy wars on code formatting:

… and  many more.

All these wars are about how text should be formatted. The very notion of code being text is so ingrained in programmers, that they often can’t think outside the box. What if the actual problem is code being text?

The problem is that text editors are stupid and don’t know how to work with the underlying graph structure of programs. But with the right tools, the editor could work directly with the graph structure, and give us freedom to use any visual representation we like in the editor. – Sergey Dmitriev, cofounder and CEO of JetBrains Inc.

This is just one of many interesting statements in the must-read article by Sergey introducing LOP. Once you consider the possibility of separating code and it’s representation, most of the code formatting discussions become obsolete.

  • Identifiers can contain spaces, or can be represented differently based on preferences. Heck, they could be icons in a diagram.
  • Visually separating a piece of code for readability would be possible without having to split into smaller functions.
  • Multiple exit points of a function can be visualized in a diagram.

… and you can think of many more.

Modern IDEs like Visual Studio are slowly adopting alternate visualizations for code made possible by using extensions. As useful as some of these extensions are, they inherit the limitations of having to work on top of text.

If the progress on JetBrain’s Meta Programming System (MPS) is any indication of how feasible LOP will be in the future, my guess is we will be hearing a lot more from this paradigm in the years to come. A new actionscript editor, Realaxy, seems to be more than capable of competing with existing editors, and is built entirely on top of MPS.

UPDATE: Markus Voelter announced mbeddr on his blog, the C language made extensible thanks to MPS.

UPDATE: It seems the Realaxy website no longer exists (I don’t know why), thus I linked to the wikipedia article instead.

Like me you might not have time to try out MPS properly, but I can highly recommend subscribing to their blog. New screencasts are appearing at a regular basis, showcasing features ranging from implementing new language keywords to creating a visual editor for a state machine.

  1. #1 by Greivin Lopez on October 10, 2013 - 6:22 pm

    This is good but the main reasoning behind code formatting is not only style but is also associated to maintenance. I’m not advocating to any particular style since I’m proficient in various different programming languages: Python, Scheme, Go, C#, VB, Java, among others.

    I have found that working on legacy code is more easier if the original developer follows the established standard for the language used to code.

    • #2 by Steven Jeuris on October 10, 2013 - 6:55 pm

      Did you intend to comment on the CamelCase vs underscores article? I don’t see how this is related to this post: “Once you consider the possibility of separating code and it’s representation […]”

  2. #3 by Nicholas Perry on June 25, 2014 - 11:36 am

    A lot of Bret Victor’s work detail what a non-text based programming “langauge” may look like. He’s even got it down to implementation examples!

    I really like his talk “Inventing on Principle”: and I think you may get a kick out of “The future of programming”: , (see more at, or his homepage )

  1. CamelCase vs underscores: Revisited « Whathecode

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: