Hacker News new | ask | show | jobs
by amw-zero 2125 days ago
I think a graph is how we perceive code, I just think the human brain has a very unique way of comprehending graphs. It seems to me like the graph is “indexed” in multiple different ways, so that multiple paths exist between nodes. The brain is also better at categorizing nodes - e.g. “fetch everything that I know about colors in general.”

I definitely think of code in graphs, but it’s definitely beyond just a static graph diagram.

2 comments

Graphs and tags for me, It's hard to describe but I can picture parts of the codebase I've worked with but only roughly until I need to interact with them then I can hold those details in my head but I lose that clarity somewhere else - I think it's a cognitive limit I have, I don't know where that lands against other developers and to an extent I think it can be trained.

As a lead/senior the thing I've observed as the crucial difference between say someone with a year or twos experience vs someone at my point is how fast I can get up to speed with a codebase I've never seen/touched.

Partly I think it's knowing how to use the tools better to get the answers I need and partly pure cyniscism, I've learnt to turn off the "if this was done sensibly" bit in my head so I can actually see what it's doing over what it probably should have actually been doing.

One of the things I really focus on with my juniors is how to use the tools available (and an A4 pad and pen) to figure out what the system is actually doing.

Can't speak for you, but I think a lot of that comes from experience, e.g. put out fires caused by whatever stupid reason, and eventually build up awareness of what could go wrong. Therefore, without reading too much into the code, simply being aware of their existence becomes largely helpful.
Agreed that our brain comprehension goes far beyond just a static graph. Ultimately I want to see all functions as fluid, which can answer dynamic questions like "show me the journey from this input data to that database update query". I think namespace/module/class/method are all valid ways to help organize this mental understanding, but they're also in a rigid form and failed to capture the dynamic nature. I think a 2D graph like Codemap opens up the rigidity a bit, but not entirely yet.
The path you describe ("input data to database query") is most certainly representable by a graph. I'm not sure what you mean by "static graph." I do believe our memory is persistent, "static," and finite. We hold discrete pieces of information and connections between them. Aka, a graph.