3 ms·
Do you think about code as a tree? It is, in some ways, but this is not the best model to reason about code, IMHO.
by stephc_int13 6y ago
Do you think about code as a tree?
It is, in some ways, but this is not the best model to reason about code, IMHO.
- gpm 6y agoI do when I'm trying to operate on it with other code (e.g. compile it - equivalently render the gui). Typically you parse it into a syntax tree.
- stephc_int13 6y agoIf you had to reason about your code as a tree when writing it, I think it would quickly be cumbersome. Remember that we're talking about the API here, not the internals of the implementation.
- gpm 6y agoIf I had to explicitly say "tree", I agree. But if what I was writing was in fact not a tree, I think it would be substantially more difficult. Sound theoretical underpinnings are usually necessary for a coherent system that allows for good abstractions. Note that in code while I don't say the word "tree" while writing it. I create a tree with my braces (C) or indentation levels (python) and file structure. The language designers created a syntax using a tree. And so on. I guess what I'm saying is that while the tutorial should not say tree, and I should not be thinking about tree nodes and edges while writing it, I should be writing a tree (and in code I am).
- stephc_int13 6y agoI almost never think about anything as a tree, especially when I am trying to solve a problem with code. I am familiar with the structure, but I've never found it practical as an abstract tool.