Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I was reading an old Coding Horror article about indentation, when I read this:

Or, maybe you're using a next-next-generation editor that treats code as "data" and the layout (including whitespace) as a "view", making all these concerns largely irrelevant.

Exactly what next-next-generation editors was Jeff Atwood referring to?

share|improve this question
    
Funny, I thought the same thing when I read that sentence. –  Ajedi32 Jun 18 '13 at 15:42
add comment

3 Answers

up vote 6 down vote accepted

The editors Jeff Atwood is talking are editors we may expect to have in future. I believe he hadn't any existent one in mind, but maybe I'm wrong.

This being said, the tabs vs. spaces issue he's talking about is largely solved by some today's IDEs. Visual Studio, for example:

  • Adjusts spaces for you, making it easy to keep the same formatting in your code and never care about spaces. For example if you start typing:

         if  (! this.isDead )
     {
    this.Kill  ( ) ;
        }
    

    it will fix it for you while you type:

    if (!this.isDead)
    {
        this.Kill();
    }
    
  • Let you to reformat the document¹ with Ctrl+E → Ctrl+F (or Ctrl+Shift+F in Eclipse), if you still succeeded in messing up with spaces.

  • Enforces either  tabs or  spaces rule: if you open a document which contain both spaces and tabs, you will be asked if you want to transform tabs to spaces or spaces to tabs or keep everything as is.

  • Adjusts the indentation according to your settings, which makes it irrelevant to discuss the number of spaces per indentation (four vs. two for example) inside a team.

Another point is that today's IDEs are powerful enough to provide better visualization of code, making whitespace/tabs/indentation discussions less relevant in some circumstances. Instead of visualizing code as code, i.e. in plain text, you can view and manipulate² diagrams, graphs, etc. Visual Studio, for example:

  • Provide designers for a lot of stuff. You may for example create a Windows Form just through drag and drop, and never care about how the code is written and what indentation is used. Drag and drop development is also strongly encouraged in general by Microsoft and they are working hard on providing different means of creating code without writing it manually. Aside personal opinions (mine being particularly negative³), this drag and drop paradigm let you imagine what would be the next-next-generation editors and how they will abstract the tabs/spaces/indentation discussions⁴.

  • Let you create the basic structure with fully documented classes, interfaces, properties, empty (not implemented) methods, etc. by using class diagrams, without ever opening the source code itself. You must still go to code to actually write the bodies of methods or properties, but still, a lot of work can be done through class diagrams⁵.

  • Let generate code from UML⁶.

To conclude, with today IDEs, you don't even need to see the source code in some cases, since you may use alternative ways of viewing code. In this case, you don't have to care about indentation. And when you have to get back to the plain text source code, the IDE is clever enough to properly format the code as you write.


¹ At least for C#. JavaScript auto-format support is pretty poor.

² The manipulation part is particularly important. If you can just view the code as data, but not change it, you still have all the issues related to whitespace, tabs and indentation. Older IDEs started to provide alternative means to visualize code, but it's only recently that it became popular to have a two ways relationship between a diagram (or other form of visualization) and the source code itself.

³ Mostly because auto-generated code is always too dirty, and is too limited in capabilities. For example, for the last ten years, each new WYSIWYG promised clean HTML and CSS, and still when you need clean code with CSS sprites and other advanced features, you will need to do the work by hand.

⁴ The code created by Windows Forms designer may not comply to StyleCop rules, but still, I never had to fix indentation for the auto-generated Windows Forms code.

⁵ The generated code violates magnificently lots of StyleCop rules, which means that the usefulness of class diagrams to generate code is rather limited if you care about style. Still, it takes away from you the care about whitespace, tabs and indentation.

⁶ I never tested this feature, because I don't have TFS. From what I remember, you can actually generate source code from some diagrams with VS2010 Ultimate + TFS. If I am wrong, feel free to edit my answer or adding a comment.

share|improve this answer
1  
Same thing for Java. On Eclipse Ctrl+Shift+F will auto-format your code. –  Vitalij Zadneprovskij Apr 28 '12 at 20:15
1  
I agree that this is a very time saving feature. In eclipse (for instance), we can agree in my team on a common code style, and then export that code style to the team members. Very handy. –  Theodor Apr 28 '12 at 21:33
    
Using actual characters to indent text is an anachronism, it's wasteful and makes reviewing and differencing more complex. Word processors figured this out a while ago, it's now time that code editors followed suit. Auto-formatting tricks like those described simply make indent characters even more irrelevant. –  pgfearo Apr 29 '12 at 15:48
add comment

Jeff was probably refering to projectional editors that actually work on the abstract syntax but only visualize text, graphics or other editable representations of the data. Jetbrains MPS or the Concrete Editor are such tools. The induced represenation of the data is actually a pro and a con since the data itself is likely to be persisted in a binary format thus is cannot be edited with traditional tools like plain text editors.

share|improve this answer
    
I like the concept of the Concrete Editor. I could actually see that scale to larger (not necessarily big) projects. –  Theodor Apr 29 '12 at 9:59
    
Instead of traditional 'plain' text editors, you can have e.g. the 'cell' editor of MPS which feels the same way but has a lot of advantages. Thanks for this answer! It deserves going a bit more in detail though. –  Steven Jeuris Apr 29 '12 at 16:45
add comment

I use the term 'Virtual Formatting' to describe the behaviour when code is formatted as you type or drag-and-drop, text is rendered using dynamic margins without the aid of any tab or space characters. Code simply re-flows into a new formatting shape automatically as the context changes. Special provision is made to ensure code doesn't move around too much whilst you're still typing though, as this can be a distraction.

If you're interested in virtual formatting, there's a video here that shows the behaviour of a freeware XML editor that I distribute as a proof of concept that also happens to do something vaguely useful.

share|improve this answer
    
Yeah, it is interesting to speculate weather things like block based drag and drop programming (like Simulink, LabView etc) is the future of code editing. Attempts have been made for a long time of simplifying the experience for the coder, but as of april 2012, C is still the most popular language (tiobe.com/index.php/content/paperinfo/tpci/index.html), and I think that says something about the need for a relativly low level of abstraction. –  Theodor Apr 29 '12 at 9:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.