4 ms·
Structural editors are great, and normal text-based programming editors should probably support the same kinds of transforms, both precisely and fuzzily. But a
by Rusky 8y ago
Structural editors are great, and normal text-based programming editors should probably support the same kinds of transforms, both precisely and fuzzily.
But a typical editing session will go through a lot of "invalid" states by design. Trying to enforce that structure is preserved at all times is a hindrance in many scenarios.
And further, if you bake structure into your editor in that way, it's much harder for anyone to invent new structures. Having good tools for unstructured text editing is valuable as, if nothing else, a fallback for when your structured editor doesn't understand the language you're editing.
- gmueckl 8y agoInvalid states should only need exist in terms of virtual placeholders for elements required by the grammar, but not filled in by the user. I have a (unsupported) suspicion that directly editing a syntax tree when gaps in its structure ate allowed is no more cumbersome than editing the textual representation. My understanding is that tools like Eclipse and Resharper work on pretty similar models internally to prevent complete failure to understand a code file while it is being mangled by the user.
- Rusky 8y agoYes, but that requires a lot of language-specific work and heuristics to make work, and there are still a lot of places where the approach falls down. (Source: I work on precisely that sort of tool for C++.) So you need the text-based fallback here, and you still need it anyway for the case of editing something a structure the editor doesn't know.
- gmueckl 8y agoC++ is the worst possible language in this case. Its complexity is immense and the C preprocessor layered on top makes a straight mapping between code and syntax tree impossible to achieve in general. Simpler languages like Java or C# (at least relative to C++) allow such syntax tree based tools to reach much, much further. I do believe that it should be possible to build an editor for "nice" languages of that kind that is entirely based on editing the syntax tree.