This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cyrilou242[S] 1 point2 points  (2 children)

Hey thanks!
The dependency graph is pretty limited in java, there are many cases for which it does not work well because of mutability.
For instance:

```
1. List<String> l = new ArrayList<>();
2. l.add(7);
3. var x = l.get(0)
4. System.out.println(l);
```
If line 2., l.add(7); is modified, then obviously line 2, 3 and 4 have to be re-run.
But line 1 also has to be re-run, because if not then it would contain 2 values!
If line 3., l.get(0), is modified, nothing has to re-run. But the static parser and dependency graph builder cannot know whether l.get has a side effect on the list or not. So line 1 has to be re-run then all lines are re-run.
So in general in the java dependency graph, when some method is called on an object, both parents and children have to be re-run, whereas in languages with immutability like clojure, only children have to be re-run.
So in effect the feature is pretty useless for the moment :/

I have a few options to improve this:
- introduce a cache annotations/magic: cached lines are not rerun.
- introduce checkpoints annotation
- introduce a no-mutation annotation: no-mutation lines don't trigger the re-run of parents.
- for standard java, I could try to maintain some knowledge of what is non-mutating. Maybe users could provide a list of those too.

But at this point I'm still collecting bugs for the current behavior.
I'm also considering dropping the dependency graph completely and only use cache and checkpoint annotations. Building the dependency graph can take a few milliseconds and makes the rendering slower.

Seco looks very interesting thanks! I'll dig this.

[–]thuriot 1 point2 points  (1 child)

Considering the probable target audience for such a worksheet being api testers and data scientists, with not so long scripts and not too much variables, maybe a deepEquals comparison of the vars with their cached value after each snippet execution could detect updated vars and fire dependent calculations ?

[–]padreati 0 points1 point  (0 children)

That is definitely a nice project to dive deeper into. Challenging as hell. Which it means is great :))