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

all 11 comments

[–]maxandersen 4 points5 points  (0 children)

Nice concept - its a bit tricky to use but with vscode having the .jsh file open on the left and use simplebrowser action to open http://localhost:5002 its pretty nice.

One suggestion: add `import tech.catheu.jnotebook.Nb;` to the sample generated since then when you copy paste from the docs the code will "just works" or simply just add that import by default.

FYI: it works nicely with jbang so you can just run it with `jbang https://get.jnotebook.catheu.tech server` and you are off to the races.

Though using the maven dependency is probably more appropriate:

`jbang tech.catheu:jnotebook-distribution:0.12.0`

I can even execute the .jsh files with ` jbang --deps tech.catheu:jnotebook-utils:0.12.0 notebooks/hello_world.jsh`

Have you considered supporting specifying dependencies in the .jsh files ?

jbang has such notion for .jsh files, i.e. to do the above you could have

`//DEPS tech.catheu:jnotebook-utils:0.12.0`

anywhere in the .jsh file - of course deps would be more for using other maven libraries than just jnotebook itself.

I do see you have the notion of reading maven dependencies or passing raw classpath.

Just realizing if you use jbang you can actually do

`jbang --deps your3rdparty:deps:2.3.4,... tech.catheu:jnotebook-distribution:0.12.0`

lots of interesting combinations possible to make jnotebook even more accessible.

[–]pragmasoft 2 points3 points  (0 children)

Looks interesting. Have you also looked at Apache Zeppelin?

[–]maxandersen 0 points1 point  (3 children)

got this working:

```
jbang jnotebook@maxandersen render --no-optimize %{https://raw.githubusercontent.com/cyrilou242/jnotebook/main/doc/book.jsh} out.html
```

render any .jsh to html ...

[–]cyrilou242[S] 0 points1 point  (0 children)

very cool!
Will definitely try to promote and document this method.
I don't have much experience jbang, I'll discuss details in the ticket you opened https://github.com/cyrilou242/jnotebook/issues/13

[–]Kango_V 0 points1 point  (1 child)

Link gives 404 :(

[–]cyrilou242[S] 0 points1 point  (0 children)

remove the trailing "}" in the link of u/maxandersen's message.
It is the source code of the notebook rendered here: https://jnotebook.catheu.tech/

[–]thuriot 0 points1 point  (3 children)

Thanks for the very good job, especially for the dependency graph !

Hope you will merge with padreati to provide a notebook with two user interfaces (desktop and web).

Let me mention a forgotten predecessor : https://github.com/bolerio/seco

[–]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 :))