Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!mailrus!ncar!tank!nic.MR.NET!umn-cs!martin From: martin@umn-cs.CS.UMN.EDU (Johnny Martin) Newsgroups: comp.software-eng Subject: Re: Structured Editor vs. Text Editor Summary: Which is better? Keywords: language-based-editor (LBE), syntax-directed-editor (SDE) Message-ID: <9767@umn-cs.CS.UMN.EDU> Date: 29 Oct 88 00:17:21 GMT References: <3385@pt.cs.cmu.edu> <39400003@m.cs.uiuc.edu> Reply-To: martin@umn-cs.UUCP (Johnny Martin) Organization: University of Minnesota, Minneapolis Lines: 130 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 --