[comp.software-eng] Structured Editor vs. Text Editor

ntanaka@gandalf.cs.cmu.edu (Nobuyoshi Tanaka) (10/25/88)

Please forgive me if this question was discussed before.

There are two main idea for editors, I think.  One is a simple text editor,
the other is a structured editor.  The structure editor will guarantee the
result of editing is legal for the specific programming language, of course.
So, in that point, it is superior to the simple text editor.  But, I feel
most of the existing structure editors are not so friendly for me.  Say,
when I want to move a cursor downward and to insert words, I may not do it
straight in the structured editor.  How do you think?  I know, it may
depend on programmers' taste.  Or, does anyone around there know the editor
that has both characteristics of the text editor and those of the structured
editor, i.e., in which we can move the cursor in the same way as in the text
editor and which guarantees the result of editing are legal to the language?

Any opinions and suggestions are appreciated.  Please send me an e-mail.
I will post the summary.

Thanks in advance and I apologize this is in poor English.

wsmith@m.cs.uiuc.edu (10/26/88)

>There are two main idea for editors, I think.  One is a simple text editor,
>the other is a structured editor.  The structure editor will guarantee the
>result of editing is legal for the specific programming language, of course.
>So, in that point, it is superior to the simple text editor.  But, I feel
>most of the existing structure editors are not so friendly for me.  Say,
>when I want to move a cursor downward and to insert words, I may not do it
>straight in the structured editor.  How do you think?  I know, it may
>depend on programmers' taste.  Or, does anyone around there know the editor
>that has both characteristics of the text editor and those of the structured
>editor, i.e., in which we can move the cursor in the same way as in the text
>editor and which guarantees the result of editing are legal to the language?

My research group at the University of Illinois has written a language 
oriented editor, Leif, that has most of the characteristics you describe.  
First, the program may be edited with text editing commands and the text is
also analyzed to locate syntax errors.  Also, commands are available to select
syntactic elements of the program.  Leif may be targeted to several
different languages by writing a new specification in Bison and Lex.

I believe that guaranteeing that the result of the editing is legal in the
language is too strict.  When I am translating a program from one language to 
another, or performing a complex editing change, I often make the program 
syntactically incorrect but will the later correct the error.  Leif 
accomodates this desire by postponing its analysis until a request is made.  
The command move-to-error will find any syntactic errors and help correct
them.

Leif is available via anonymous FTP from a.cs.uiuc.edu (cd pub/Leif) and 
other arrangements are possible if FTP is impossible.
----------------------------------------------------------------------------
Bill Smith			|  Mail sent to leif@cs.uiuc.edu or 
wsmith@cs.uiuc.edu		|  uiucdcs!leif will go to our research group 
uiucdcs!wsmith			|  headed by Roy Campbell.

malcolm@alf.UUCP (Malcolm Colton) (10/28/88)

In article <39400003@m.cs.uiuc.edu> wsmith@m.cs.uiuc.edu writes:
>
>There are two main idea for editors, I think.  One is a simple text editor,
>the other is a structured editor.  The structure editor will guarantee the
>result of editing is legal for the specific programming language, of course.

In the PC marketplace, Brief from Underware and Associates (?)
is fully programmable, using a lisp-like language. There are sets of macros 
available that support syntax construction in C, dBase, and (I think) Pascal. 
This is somewhat short of syntax _checking_, but gives you faster 
syntactically correct program entry.  You can override the actions of the 
macros at any time with the cursor keys.

With a lot of ingenuity and skill, you could write syntax checking macros.
---------------------------------------------------------------------------
Malcolm Colton				       Sybase, Inc., Emeryville, CA
{pyramid, pacbel, sun, mtxinu, capmkt}!sybase!malcolm
___________________________________________________________________________

martin@umn-cs.CS.UMN.EDU (Johnny Martin) (10/29/88)

In article <39400003@m.cs.uiuc.edu> wsmith@m.cs.uiuc.edu writes:
>
>>There are two main idea for editors, I think.  One is a simple text editor,
>>the other is a structured editor.  The structure editor will guarantee the
>>result of editing is legal for the specific programming language, of course.
                       ^^^^^
 -- NOT ALWAYS TRUE.
>>So, in that point, it is superior to the simple text editor.  But, I feel
>>most of the existing structure editors are not so friendly for me.  Say,
>>when I want to move a cursor downward and to insert words, I may not do it
>>straight in the structured editor.  How do you think?  I know, it may
>>depend on programmers' taste.  Or, does anyone around there know the editor
>>that has both characteristics of the text editor and those of the structured
>>editor, i.e., in which we can move the cursor in the same way as in the text
>>editor and which guarantees the result of editing are legal to the language?
>
>My research group at the University of Illinois has written a language 
>oriented editor, Leif, that has most of the characteristics you describe.  
>First, the program may be edited with text editing commands and the text is
>also analyzed to locate syntax errors.  Also, commands are available to select
>syntactic elements of the program.  Leif may be targeted to several
>different languages by writing a new specification in Bison and Lex.
>
>I believe that guaranteeing that the result of the editing is legal in the
>language is too strict.
 -- I CANNOT DISAGREE MORE.

  When I am translating a program from one language to 
>another, or performing a complex editing change, I often make the program 
>syntactically incorrect but will the later correct the error.  Leif 
>accommodates this desire by postponing its analysis until a request is made.  
 -- IN A TRUE SDE, TRANSLATION CAN BE AUTOMATED.

>The command move-to-error will find any syntactic errors and help correct
>them.



There appears to be much confusion about the current state of development
in language-based editors.  Perhaps this is due to the fact that most of the
research issues have been settled, and that building a good editor has become
an engineering problem.  We must now rely on industry to produce syntax-
directed editors that are of production quality.

First of all, lets get the terminology straight.

  LBE, language based editor = an editor that knows something of the program
    under construction.  This is a broad definition.  For example, emacs with
    its minor modes probably qualifies as an LBE, as do some of the PC-based
    Pascal editors.  CPS (the Cornell Program Synthesizer) also falls under
    this definition.

  SDE, syntax directed editor = an editor that rigidly conforms to the syntax
    of a program language, i.e. its CFG or BNF definition.  These editors have
    the BNF built right in.

  structure editor = although this refers to any editor that is capable of
    editing some possibly non-syntactic structural object, its common use
    in the literature refers to SDE.

Now, back to the state of the point...
Syntax-directed editors can be as "user-friendly" as text editors, and
Syntax-directed editors can provide editing (transformational) power than
text editors.

1. SDE's do not guarantee that (just because the syntax is correct) a program
    will compile correctly.  Consider type checking or scoping errors.

2. The SDE's that are popular in the literature (e.g. Cornell's CPS,
    Carnegie-Mellon's ALOE, etc.)  are wonderful, "proof-of-concept"
    projects, but are basically unusable tools.   Poor user interface, slow
    as molasses, etc.   I have not seen Leif, but its description does not
    sound promising, as a research project or otherwise.

3. Editors which claim to be syntax directed, but are actually just text
    editors with a syntax checker running in the background, are a sorry
    excuse for avoiding the user interface problem of SDE's.  They won't
    be able to perform some of the powerful transformations that a true
    syntax-directed editor might.  (Note Bill Smith's comments above about
    introducing errors intentionally to effect a transformation!)
    DISCLAIMER: obviously, since emacs is Turing complete it could simulate
    everything a SDE does, but slowly.

4. True syntax-directed editors with nice user interfaces are a godsend.
    The hardest part about implementing a syntax directed editor is the user
    interface.  Getting those arrow keys to correspond to the right tree
    traversal, while appearing to move only one character on the screen
    is tough.  It seems our friend has avoided this by implementing a text
    editor, instead.

    True SDE's have great power, since the program tree is right there
    they can perform seemingly impossible transformations.
    Besides the neato stuff for filling in templates, at the
    touch of a button a good SDE might...

      A. transform one indentation scheme to another
      B. highlight keywords
      C. conversion from Pascal code to Ada code
      D. display only procedure calls without bodies
      E. other types of summaries (showing only relevant details of constructs)
      F. ellipsis (hide the parts of the program I don't want to see)
      G. display only documentation/comments
        (nice for managers that can't read code)
      H. display only raw code
        (nice for hackers that can't read documentation)
      I. display the code in another spoken language
        (nice for immigrant workers that can't read English)

  I would suggest taking the time to become familiar with a good SDE with
  all the bells, and whistles, and user interface stuff before you decide
  that text editors are the only answer.   

  For example, my favorite SDE in the Program Composer, by Xinotech Inc.
  The Composer is perhaps the first production quality syntax directed editor
  ever made. It has all of the features above, uses fancy windows and a mouse
  interface.  I don't know how much it costs, but it's probably worth whatever
  they charge.

  Their address is,

      Xinotech Research, Inc.
      Technology Center, Suite 203
      Minneapolis, MN  55414

      (612) 379-3844

  I think they give out demo copies, but I'm not sure...-- 
Johnny Martin, Dept. of Computer Science, University of Minnesota, Minneapolis
martin@umn-cs.cs.umn.edu
--

wsmith@m.cs.uiuc.edu (11/05/88)

I will try to briefly respond to the points raised by Johnny Martin.

First, one should not make generalizations about an editor based on such a
short description.  Leif is a complex program that is more than a "background 
syntax checker."  It contains an incremental parser that efficiently 
maintains a parse tree that may be consulted to visualize the syntactic 
structure of the program as well as locate errors.  Leif is definitely not 
slow.

Secondly, there are other ways of categorizing language oriented
editors.  Martin's categorization begs the question by implying that "True
SDE's have great power" and thus must abandon text editing commands to provide 
this power.  Leif does not yet provide all of the transformational 
power of the ideal philosopher's stone SDE but it provides enough power to
be worthwhile.

While emphasizing that a nice user interface is "a godsend," he assumes that 
text editing does not fit in such a user interface.  Consider Richard Waters 
article "Program Editors Should not Abandon Text Commands."  Syntax directed 
editing is possible within a framework of textual editing and Leif proves 
that.  The transformation and holophrasting capabilities espoused by Martin 
are possible within the Leif framework although they have not been 
implemented yet.  I believe researchers at Berkeley are also independently 
developing an editor with similar capabilities to Leif.

Transformational commands are valuable, but is it possible to proved a complete
set of such commands?  Many transformations should be based on semantic 
information which may be unavailable because of undecidability of understanding
some aspects of programs.

Martin implies that a programmer only wants to use a language oriented editor
on a fixed, standardized language.  In my research, Leif demonstrates that there
is a demand for easily constructed language oriented editors. In Leif, it 
takes only a few hours to create an useful editor once a lexical analyzer and 
LALR grammar have been written.  The problem of creating a useful set of 
transformations is difficult and time consuming.  Similarly, writing emacs 
lisp code to edit in a new language-sensitive mode is non-trivial.

By quickly developing an editor for a special purpose language, the quality
of the language may be improved through an iterative design process.  This
same design process may be used to teach compiler design techniques.
Leif allows many different languages to be edited with no modifications to
the user interface.

The original question that started this discussion demonstrates that the 
design of language oriented editors still pose several research questions.  
The foremost research issue is the user interface.  Leif provides a user 
interface that is radically different that that provided by Xinotech's 
Program Composer that Martin champions.

Finally, evidence that language oriented editors (or syntax directed editors)
are not a solved problem is that they are not widespread and they have only
a limited user community.  Research should continue to improve the tools
available to programmers beyond the limited editing techniques available now.

Bill Smith
wsmith@cs.uiuc.edu
uiucdcs!wsmith

dg0f+@andrew.cmu.edu (Dennis Goldenson) (11/06/88)

Whether it's a "fact that most of the research issues have been settled" is
arguable.  But structure editors do indeed exist that integrate the kinds of
functionality Johnny Morris describes and more into an intuitively graceful
and often "text like" user interface.

Two environments developed at Carnegie Mellon for Pascal and the Karel the
Robot teaching language are available for the Macintosh through the Kinkos
Academic Software Exchange.  Called GENIE both are intended for use in
introductory/intermediate level programming methods courses.