1. 6
  1.  

  2. 3

    Prediction 3: Tree Oriented Programming (TOP) will supersede Object Oriented Programming. A new style of programming, TOP, will arise. TOP programmers will frequently reference 2D views of their program.

    The quote above is from one of the papers about TreeNotation. In my understanding TreeNotation defines a syntax but no executable semantics. Object Oriented Programming on the other hand refers to an execution model that involves, among other things, the execution of methods and dynamic method lookup. I fail to see how a syntax can supersede an execution model.

    1. 2

      You can actually reshape the tree representation in OP to be an s-exp. I guess Tree Oriented Programming, in the end, is isomorphic to LISP.

      1. 1

        Great question!

        In my understanding TreeNotation defines a syntax but no executable semantics.

        Yes! Precisely.

        I fail to see how a syntax can supersede an execution model.

        Version 14 of the Ohayo app is approaching the realization of what I meant by “Tree Oriented Programming”. Hoping to release the source code to Ohayo soon, and not just the compiled version. The whole thing will be a 2D geometric tree in both syntax AND semantics (in Tree Notation, we can get the abstract/syntax stuff without mutating the underlying syntax/code). So no matter how you look at the code, whether at the raw syntax/code or the parsed version, it’s a tree.

        There are definitely connections to OOP too though. We have “nodeTypes” which are our classes. And then we have trees, which are instances of those nodeTypes. We have abstract and access modifiers and inheritance, etc.

      2. 2

        Is there some docs on writing the grammar? I like where the project is going (I remember your last post here).

        This may be a silly question, but how do you represent a list of nodes (I see named maps in the examples) and attributes?

        1. 1

          We don’t have good human made docs yet on Grammar authoring. I know some volunteers were working on that, but I don’t think they’ve published anything yet and not sure the timeframe.

          Here’s the best we have at the moment: http://treenotation.org/sandbox/build/#standard%20grammar

          The Grammar language is itself written in the Grammar language. So any keyword you see in “foo.grammar” will be defined in “grammar.grammar”.

          I’m also hoping we will add auto-generated docs by the end of the week (https://github.com/treenotation/jtree/issues/26).

          how do you represent a list of nodes (I see named maps in the examples) and attributes?

          The base node actually has children as a list of nodes, and not a named map. Thank for asking that (a few folks have had questions about that and so it I just created an issue to improve it). Here’s the basic data structure:

          interface TreeNode {
            parent: &TreeNode
            children: TreeNode[]
            line: string
          }
          

          The Stump Tree Language, which compiles to HTML, implements a list of htmlTag nodes with attributes, may serve as a good reference: http://treenotation.org/sandbox/build/#standard%20stump

        2. 2

          It looks like a way to save AST to a file system. Is that right?

          1. 1

            Yes, in a sense that is right.

          2. 2

            How do I represent a line that starts with whitespace? How do I represent text with multiple linebreaks?

            1. 1

              Below is an example you can paste into http://treenotation.org/sandbox/build/#standard%20stump.

              Click compile to see how it works.

              I also embedded the code in this link.

              pre
               bern
                
                Hello hwayne
                this is some text with line breaks and newlines.
                
                
                Above are 2 blank line