Live data from Hacker News

Why Don't We Have a General-Purpose Tree Editor? (2014)

pcmonk.me

211–220 of 222 posts

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#211
imagine you had about ten excel tables linked in a graph, any interesting visualization or analysis involves querying it like a database, and many databases are very rigid in terms what they can store, not flexible like excel. Semantic web stores (triple stores) are mostly schemaless and solve the rigidity but they had their own problems [1], datomic's 5-store model maybe fixes them? So maybe we will see an excel-for-graphs based on datomic someday soon. I'm working on this problem so if anyone has any interest in discussing this you should email me! It's a really interesting problem because excel-for-graphs would be an amazing starting point for building CRUD apps.

[1] can anyone help me with clarity here as to why triple stores failed? Is it because no :db/retract and no time axis so cache consistency problems? or a deeper reason?

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#212

Earlier quoted context omitted.

Your representation is certainly valid , but I think those properties (light-weight, intuitive, etc.) apply to your example rather than your representation. For example, imagine representing the HTML of this Hacker News page in your format; it would be completely unwieldy, and Hacker News is notoriously simple as far as HTML goes. It's clear that this representation is massively space inefficient, since it repeats th…

>> For example, imagine representing the HTML of this Hacker News page in your format; it would be completely unwieldy, and Hacker News is notoriously simple as far as HTML goes. Well yes, but that's because HTML is a mess, not because graph notation is unwieldy. In any case I don't think it's a good idea to try to program in graph notation, or anything like it. Actually, I think it's a terrible idea. Unless you want…

> Manipulating graphs, er, graphically, will not give you some sort of magical get-out-of-jail-free card against syntax errors or undefinable behaviour etc.

It does prevent some errors, like malformed structures. For example, the following Lisp:

    (defun (square x (* x x))
Or the following C:

    void square(int x {
      return x * x;
Or the following Ruby:

    while $i 
These sorts of things can occur when manipulating programs at the character level, but they're inexpressible at the level of parse trees/graphs. Balancing parentheses, braces, quotation marks, begin/end, etc. is exactly the sort of task that machines can automate away.

The idea of a general tree editor is not to prevent syntax errors, undefined behaviour, etc. because those are properties of specific trees, e.g. the parse trees of C programs. A tree editor just edits trees; it doesn't care what those trees represent (that's why the author mentions a plugin mechanism, like Emacs has different modes for editing files written in different languages).

Manipulating programs at the level of parse trees can also be more efficient, less tedious and prevent errors, e.g. see the paredit videos linked in other comments. By analogy, what's the point of a general text editor, when our CPU can already perform arithmetic on bytes? A general text editor doesn't prevent syntax errors, undefined behaviour, etc. Does editing strings of text, rather than numerical bytes, provide expressive power or syntactic clarity that we don't have with high-level languages already?

I also don't think the author was asking for something "graphical" or "GUI" per se; their analogy is with text editors (e.g. Emacs and Vi), which are efficient both in their display and their interaction. A general tree editor wouldn't be based around e.g. drag'n'drop of nodes/edges, in the same way that general text editors aren't based around drag'n'drop of glyphs in a grid.

General text editors have features for moving to the start/end of a line, for cut/paste up to the next space or linefeed, for highlighting parentheses, for folding/unfolding between sentinel characters, etc. General tree editors would instead have features to move to the root/leaf of a tree, cut/paste sub-terms, fold/unfold expressions, etc. No need to care about the existence of whitespace, linefeeds, indentation, parentheses/delimiters, etc. they can all be handled mechanically.

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#213

Trees are graphs with out cycles but you always end up adding cycles. Code is no exception. There have been endless attempts to create coding systems based on graphs. These systems promise extraordinary modularity and reusability and an ease of programming which will allow anyone to construct complex software with a few clicks and drags. So far everyone of these systems that I have seen in the last 25 years has falle…

Unreal Engine 4 has Blueprint, which is a powerful node graph programming system. It works great and it's very popular. It's definitely worth looking at for anyone interested in this sort of thing. The "bi-directional flow" (exec nodes "push", data nodes "pull") makes it very flexible for almost any kind of task.

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#214
post #51

We do: http://strlen.com/treesheets/

I just tried this on macOS. I really like the concept but: It does not conform to macOS UI standards (I could live with that), and it is very slow (I cannot live with that).

It uses wxWidgets for UI, which does a poor job on OS X. What actions are slow? I have it here on a MBP and it appears to work just fine.

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#215
post #43

We do: http://strlen.com/treesheets/

Seems like a enhanced personal wiki and away from PIM style and more added MindMap style. I would say this is not a tree editor.

It allows you to edit a tree structure. Unlike most tree editors, which lay out the tree in one dimension, this uses 2 dimensions. How is that not a tree editor other than it looking unfamiliar to you?

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#216

Earlier quoted context omitted.

>> For example, imagine representing the HTML of this Hacker News page in your format; it would be completely unwieldy, and Hacker News is notoriously simple as far as HTML goes. Well yes, but that's because HTML is a mess, not because graph notation is unwieldy. In any case I don't think it's a good idea to try to program in graph notation, or anything like it. Actually, I think it's a terrible idea. Unless you want…

> Manipulating graphs, er, graphically, will not give you some sort of magical get-out-of-jail-free card against syntax errors or undefinable behaviour etc. It does prevent some errors, like malformed structures. For example, the following Lisp: (defun (square x (* x x)) Or the following C: void square(int x { return x * x; Or the following Ruby: while $i These sorts of things can occur when manipulating programs at…

We can have editing methods that are character-based, yet which make those kinds of syntax errors impossible.

A trivial example of this are input fields which enforce a lexical format. For instance, we can implement an input field for a floating-point number where you simply cannot type some garbage like "1.E". What happens is that you type "1" (so far so good), then then "1." (still good) and then "1.E" (good prefix, but bad). Since it is a good prefix, the "E" is allowed, but the validator automatically inserts some suffix to make it valid, like 0. So you see "E0". The 0 is selected so that the next thing you type will replace it. But if you type some garbage like Z, it will be rejected; at that point you may only type a + or - sign, or a decimal digit.

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#217

Earlier quoted context omitted.

How do you feel about tools like Reaktor, which I assure you works very well indeed?

Reaktor is a audio program. There is actually a long history of this type of app working well. PD is an early example. This is indeed a limited type of programming. Above I was referring to attempts to apply this idea to general programming. I'm not saying such systems are impossible just that it's a bad idea to assume it will make the programmer's life easier.

That's not very responsive. Reaktor's primary purpose is to produce audio, but it also allows one to build sequencers, user interfaces, graphics (eg spectrograms, from DSP primitives by build your own FFT modules) and all sorts of other tools. Besides, why is audio somehow an inferior sort of data processing?

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#218

Earlier quoted context omitted.

> Manipulating graphs, er, graphically, will not give you some sort of magical get-out-of-jail-free card against syntax errors or undefinable behaviour etc. It does prevent some errors, like malformed structures. For example, the following Lisp: (defun (square x (* x x)) Or the following C: void square(int x { return x * x; Or the following Ruby: while $i These sorts of things can occur when manipulating programs at…

We can have editing methods that are character-based, yet which make those kinds of syntax errors impossible. A trivial example of this are input fields which enforce a lexical format. For instance, we can implement an input field for a floating-point number where you simply cannot type some garbage like "1.E". What happens is that you type "1" (so far so good), then then "1." (still good) and then "1.E" (good prefix…

> We can have editing methods that are character-based, yet which make those kinds of syntax errors impossible.

Your example doesn't work very well, since it's very specific (the author wants "general-purpose"), and I would say it's not actually a "character-based editing method": it has a keyboard-driven UI and a character-based display, but so does NetHack. Instead I'd say your example is a float editor, rather than a 'text editor with syntax rules'.

In any case, there is an example which is close to a general-purpose tree editor that's is keyboard-driven with a character-based display: paredit mode in Emacs, as mentioned by other comments. It's implemented exactly like you describe: many keypresses correspond to the insertion of their respective characters, but when that would invalidate the tree structure (e.g. '(' and ')' keys), different actions are taken instead. For example, '(' inserts '()', whilst ')' "steps over" existing ')' characters rather than inserting extra ones.

My issues with paredit, as I've written in other comments, are that it's stuck with a single representation of trees as parenthesised s-expressions: there's no way to alter the "view" of a tree, e.g. to a boxes-on-sticks view or a nested-boxes view (whether they're displayed using ASCII art or GUI widgets). It also leaks implementation details, e.g. altering the alignment or indentation of expressions will cause the file contents to change, despite having nothing to do with a tree.

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#219

Earlier quoted context omitted.

def f = x = readline; g x def g x = print x; f

Not 100% sure how to interpret this piece of code, but my naive interpretation gives this AST: (def f () (let ((x (readline))) (g x))) (def g (x) (print x) (f)) Writing in Lisp can open one's eyes about the underlying structure of the code.

My point was that "Code editing is tree editing" sounds a bit like if you can understand the syntax tree, you understand what the code does – which isn't true here. Trees don't show the recursion[1], and a tree-view of code (with e.g. folding) might even give a false impression that what's inside one branch is somehow self-contained. Ie. Turing Machines are more expressive than CFG's :-) Not that tree-view's aren't helpful (indentation is important, and editing Lisp with paredit is a real joy), but there's much more to code-editing than tree-manipulation.

[1] Unless your "tree"-view is actually a lazy call-graph …

Re: Why Don't We Have a General-Purpose Tree Editor? (2014)

#220
post #209

Earlier quoted context omitted.

Thanks. Or you can always use what I think is slightly informal notation, where a directed edge is notated as a -> b (I've seen that in textbooks, but I'm not sure where it's coming from).

Haven't seen this notation in text books so far, but I guess one of the following 3 things happened: (1) The notation a->b was defined as a simple shorthand, i.e. a->b := (a,b). (2) The notation a->b was defined to be the graph consisting of just a, b and the edge, i.e. a->b := ({a,b}, {(a,b)}) ... this may be followed by some algebraic rules about how to combine small graphs to build larger graphs. (3) The notation…

I believe it's (1) and I think it might originate in Judea Pearl's textbook on causality [1], particularly the section on the IC algorithm. I've also encountered it in a bunch of papers on graph reconstruction, by Wermuth, Lauritzen, Spirtes and Glymour (not all in one go, I don't think). For instance, see [2].

I guess it's convenient notation for a typical step in those algorithms, where two edges are oriented towards a common vertex- shown as A -> B ___________________

[1] Causality; models, reasoning and inference:

http://bayes.cs.ucla.edu/BOOK-2K/

[2] A Fast Algorithm for Discovering Sparse Causal Graphs; Peter Spirtes & Clark Glymour:

http://repository.cmu.edu/cgi/viewcontent.cgi?article=1316&c...

Post reply on HN