Nobody asked, but I am going to explain one Saturday morning tweet about traversal.
Here are few things which should help few of you to get into same world as my brain see.
Traversal in my world is about going from one piece of data to another by using well-defined relationship in a computer system. It sounds very abstract and it is, more over it clashes with many normal meanings, semantic and forms of the word “traverse”. Please bear with me, I don’t have any better term for now. Important detail here is that there is a process to go from A ⮕ B, because relation between A and B have been defined magically somehow.
Context is a simple to not-that simple knowledge of a very fine grain detail of data. A clue how to interpret things. Like this value indicates container, that one is color and another one is email address, or this random number is a user session.
But, and here is the thing, which makes me uneasy and excited at the same time: it should be enough to generate relations based on any structural-like input and finite defined contexts and by traversing this input.
If that so, can I reduce all traversals to well-known classical algorithms (DFS/BFS)? Will it be enough to generate any complex model to describe any knowledge using just simple traversal? Could context be 100% decoupled from the process when it comes to knowledge generating?
Time to get hands dirty.
Research plan starts from testing
Any structured input like well-know formats like JSON, YAML, GraphQL, XML would do it.
Then parser should generate stream of tokens and let DFS implementation to take it over. In some way it will be re-implementation of existing functionalities of a parser to convert input into abstract syntax tree (AST).
The part in parser which does interpretation of tokens into AST is hard coded in all known to me implementations. My claim: hard coded piece can be decoupled by using context-aware traversal.
Last piece is a traversal library, I plan to use traverser since it does provide a way to generate context per every visited node.
So, the first test would look as following, input:
{"MyFieldName":"some value"}
And then I will try to generate an AST using DFS on input, and some code which would recognize every token and perform two things:
— generate children for a given token
— instantiate context(s)
Jackson looks as good choice as parser for JSON, given it has multiple parser options.