I'm gonna do something I don't normally do and call out a project as being good but not good enough. I don't normally do this because it feels a bit like infighting. Here are some people doing exactly the sort of work I want to encourage more people to do! But, I'm trying to come at this like Alan Kay when he said the Macintosh is the only computer good enough to be criticized.
This project — Lem — is an editor/IDE written in Common Lisp. It seems pretty cool. One feature is called Living Canvas:
Living Canvas is a visual code analysis feature that displays function call graphs as an interactive, Figma-like canvas. It helps developers understand code structure, relationships, and execution flow.
There's a nice video on that page which shows how you can interact with this visualization to browse through a codebase, viewing relationships between units of code and jumping to definitions. Pretty nice!
But… but but… they describe it as "figma-like". If this were actually figma-like:
- I'd want to be able to write / draw on the canvas, to leave myself notes about the structure of the codebase.
- I'd want this canvas to be a collaborative space, so that other people could join me as we talk about and make notes about the architecture of our project.
- I'd want to be able to embed other media, like links to docs, github issues, pdfs, ADRs, etc, and pepper them around the graph.
- I'd want to be able to group nodes as I see fit, rather than merely by file.
- I should be able to move nodes freely with the mouse. Annotations on the canvas should stay where I put them , because spatial arrangement is profoundly meaningful. But I should also be able to attach things to a node, so if I move it, the things go with it. (Final Cut Pro X's timeline makes pretty deep / fascinating use of these sorts of attachments, wildly different from all other video editors)
- I want to be able to meaningfully edit the nodes. This view shouldn't just be a viewer. I want to be able to refactor a function by (eg) double clicking a node to view its source code, selecting some of that code in the text editor, then dragging it out into an empty spot on the canvas, typing name for a new function, and having a reference to that name appear in place of the selected code. This is a lisp, so it should be able to do a pretty good job of handling this sort of structured edit.
- I want other views, not just functions-as-nodes. Maybe a view of variables. Maybe a view of tests. Maybe a view of types / data structures. Figure out how to make these meaningfully spatial, and what affordances they should have. Figure out how to use transclusions so that I can sort of "peek around the corner" from one of these views into another view.
- let me lasso some nodes in the canvas, create an isolation boundary around them, then let me feed some data in at one point and see what data pops out — sort of like a smoke test, but where I can just visually pick both the outer and innermost depth of the graph to be interested in, without having to (eg) create stubs / mocks / doubles. (this idea occurred naturally from thinking, for like 5 seconds, about drawing shapes around my code in this graph. would love to see what we could do if we thought about it for 5 minutes.)
I see two kinds of criticisms in your list:
- "Figma-like canvas" suggests visual editing and annotation, whereas Lem's visual canvas only does code-based visualization.
- Even for visualization, there is functionality I feel is missing.
I don't see 2. as a valid criticism, given that this is very new and prototypy, meaning that more similar functionality is likely to be added in the near future. And you could probably add it yourself with reasonable effort.
The interesting question now is if the same can be said for 1. The author doesn't say anything about future plans. Is code visualization only the first step, or the only goal?
Could you formulate your criticism as a suggestion, and submit it to the Lem's lead author?
My goal with this post is not to find ways to improve Lem in the hope that they'll come true, but rather to use Lem as a case study and talk more broadly about what I'd like to see in canvas-based programming tools. The intended audience is the folks here who are making canvas programming tools.
Not being a creator of canvas programming tools, this perhaps is a bit of a sidetrack, but I have a question: why haven't even the bare minimum of "let's show a diagram of a call graph" tools become more popular? Is it lack of good implementations or are they not as useful in practice as it seems like they ought to be? (Or, perhaps most likely, the usual problem of making programming easier is a difficult sell to those who make their living solving hard problems…)
I think it's all of the above and more , each cutting out some proportion of users.
One problem with call graphs is that they quickly become very big. I find local call graphs more useful in practice, i.e. call graphs that show only adjacent nodes from a starting point. You can click your way to the places you care about. More steps, but each step is mind-sized.
There is probably a use case for global call graphs in analyzing architecture on a larger scale, but then you probably want to coarse-grain the graph. I haven't done anything along those lines, so I'll stop speculating.
+1 on graininess being an issue. I look at profiler generated call graphs a lot (eg flamegraphs) and the main problem is noise. In my mind there is a higher level fuzzy picture (eg layers, components, etc) but the call graph functions are too fine grained – small util functions, every silly wrapper function, all just carry the same visual weight. A clever tool could try to infer the higher level fuzzy picture from the low level call graph. A better starting point may be the ability to represent big picture concepts directly in the program.
I"d also prefer being able to write down a big-picture view right in my code. My workaround is to use one file for each functionality chunk. But no existing tools let me visualize dependency graphs between units that are just my personal conventions.
Meaning... I should write my own graph visualization. Why didn't I think of that before??? Thanks everyone for this thread!
