Live data from Hacker News

Pluto.jl – a reactive, lightweight, simple notebook

github.com

31–40 of 63 posts

Re: Pluto.jl – a reactive, lightweight, simple notebook

#31

Earlier quoted context omitted.

The idea is to keep the amount of global state as low as possible. Pluto.jl creates a dependency graph between cells: If cell A defines foo, and cell B uses foo, then cell B depends on cell A. Whenever cell A is updated, cell B will automatically be re-evaluated. (edit: I suppose it's not really global state I'm talking about as much as hidden state left over from overwritten or deleted cells) For example, I typicall…

What happens if you reassign a variable below? Like: a = 1 println(a) a = 2 Does it show 1 or 2? Edit: tested it, it throws an error "Multiple definitions for a: Combine all definitions into a single reactive cell using a `begin ... end` block." Not sure I like that way of working.

You just update the `a=1` cell, changing it to `a=2`. That's the whole point.

Every other cell that depends upon `a` will then automatically update.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#32

Really happy to see that the good ideas from Observable notebooks are being copied elsewhere. I don't use Julia myself at the moment (although I think it's a beautiful language), but I know some people who will be very happy with this! Also, the playful enthusiasm in the presentation video linked in the description just makes me smile: https://www.youtube.com/watch?v=IAF8DjrQSSk

Very interesting, thanks. I don't understand the point of the "reactive" cell order, instead of conventionally doing top to bottom. It seems like it goes against the idea of "the program state being completely described by the code you see".

Even if you do it completely top down, it doesn't mean all cells need to update if you change something on the top, so you'll still profit from the dependency graph.

And notebooks are mostly for exploration, and you don't really have a fixed order. You start getting the data, then you run the model, then you go back and change the data in the import... The order of your internal logic (or how you want to explain it to others) isn't necessarily linear, and of course you can just go back and write like a normal program but you lose the chain of changes that led you to the result (in this case the compromise is that your chain is restricted, like you said you can't define the same thing twice, but in exchange the notebook will provide with you the program order for free).

Re: Pluto.jl – a reactive, lightweight, simple notebook

#33

I've switched from Jupyter to Pluto recently. Here's a few experiences with it. * The fact that I can actually use the source files later because they're just Julia files is incredibly useful. I often copy-paste from them into actual REPL-code, and sometimes I just polish the notebook until its source becomes usable as a command-line tool. * I like the reactive notebook concept. It does really help with bugs * Pluto…

The inability to simply import jupyter notebooks as python files has always been a point of friction for me, I’m glad to see this is a main feature for Pluto.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#34

Really happy to see that the good ideas from Observable notebooks are being copied elsewhere. I don't use Julia myself at the moment (although I think it's a beautiful language), but I know some people who will be very happy with this! Also, the playful enthusiasm in the presentation video linked in the description just makes me smile: https://www.youtube.com/watch?v=IAF8DjrQSSk

Very interesting, thanks. I don't understand the point of the "reactive" cell order, instead of conventionally doing top to bottom. It seems like it goes against the idea of "the program state being completely described by the code you see".

So in the context of these notebooks it is actually quite useful to not depend on cell order, because the idea is that notebooks aren't simply programs or scripts, they are (potentially interactive) documents. You can write an article that presents the results of your script, with cells that contain text, interactive widgets and plots at the top, and put the code and data that generates these plots in "appendix" cells below that. Observable, a "JavaScript ancestor" of Pluto.js, has plenty examples of these:

https://observablehq.com

Also, I guess that you haven't used notebook environments like Jupyter before, so a bit of historical context might help. In Jupyter, cells aren't necessarily executed top-to-bottom, they are executed when the user asks it too. The result is then stored in the global state (well, assuming there is a global variable that the data is assigned to). This means that cells that depend on other cells also depend on the order in which those cells were executed. Worse still, if you write your notebook in a sloppy manner, you can end up with a state that you cannot reproduce from the still-remaining code (for example, you can have variables A and B, B is generated from the result of A, then you remove A. Because Jupyter is not reactive this does not update B, so your notebook keeps working just fine... until you decide to edit B). So previously, notebook-like environments made it really easy to introduce bugs like this.

With reactive cells you don't have to think of state. It's kind of like pure functional programming: it removes global side-effects. And note how on a technical level, making cells execute top-to-bottom is really just very a simple way to enforce that cells must executed in order of dependency! So either option insists that this global-state-that-does-not-respect-dependencies is a big problem that should be avoided, they just present different solutions for the problem.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#35

Earlier quoted context omitted.

The idea is to keep the amount of global state as low as possible. Pluto.jl creates a dependency graph between cells: If cell A defines foo, and cell B uses foo, then cell B depends on cell A. Whenever cell A is updated, cell B will automatically be re-evaluated. (edit: I suppose it's not really global state I'm talking about as much as hidden state left over from overwritten or deleted cells) For example, I typicall…

What happens if you reassign a variable below? Like: a = 1 println(a) a = 2 Does it show 1 or 2? Edit: tested it, it throws an error "Multiple definitions for a: Combine all definitions into a single reactive cell using a `begin ... end` block." Not sure I like that way of working.

Think of it as working with immutable data, because that's essentially what it is. Which has all the pros and cons of that approach (in my opinion a lot more pros, but YMMV).

Re: Pluto.jl – a reactive, lightweight, simple notebook

#36

Earlier quoted context omitted.

Very interesting, thanks. I don't understand the point of the "reactive" cell order, instead of conventionally doing top to bottom. It seems like it goes against the idea of "the program state being completely described by the code you see".

So in the context of these notebooks it is actually quite useful to not depend on cell order, because the idea is that notebooks aren't simply programs or scripts, they are (potentially interactive) documents . You can write an article that presents the results of your script, with cells that contain text, interactive widgets and plots at the top, and put the code and data that generates these plots in "appendix" cel…

Thanks a lot for the write-up.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#37

Earlier quoted context omitted.

The idea is to keep the amount of global state as low as possible. Pluto.jl creates a dependency graph between cells: If cell A defines foo, and cell B uses foo, then cell B depends on cell A. Whenever cell A is updated, cell B will automatically be re-evaluated. (edit: I suppose it's not really global state I'm talking about as much as hidden state left over from overwritten or deleted cells) For example, I typicall…

What happens if you reassign a variable below? Like: a = 1 println(a) a = 2 Does it show 1 or 2? Edit: tested it, it throws an error "Multiple definitions for a: Combine all definitions into a single reactive cell using a `begin ... end` block." Not sure I like that way of working.

In a more complex example where you actually take a variable, do some operations to it, then reassign it, Pluto.jl encourages you to separate that into multiple cells. The reason is each cell marks a distinct node in the dependency graph. If you prefer to use cells, then the notebook can be smarter about what lines actually need to get re-run and what don't.

A downside to using multiple cells is vertical spacing/visual noise. This is something that the package authors are currently thinking about addressing.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#38

Seems really smooth. I would like to see how does this scale with larger chunks of codes. Is there any benchmark comparisons?

It just runs Julia under the hood, so I would expect it to be simply as fast as Julia (assuming that the data processing is the more significant bottleneck compared to the HTML output that is used to present the results). Performance more likely affected by the way the data is processed than the language's speed.

From what I understand, results of cells are cached though, and they don't update unless something upstream changes, so there is a form of memoization happening. Which of course also has both implications for performance as well as memory usage.

Re: Pluto.jl – a reactive, lightweight, simple notebook

#39
post #5

Earlier quoted context omitted.

would be curious what Jupyter notebooks things are better with Pluto.jl, can you name some concrete points?

1. Dependency graph for cells, letting it automatically rerun what's needed when you change one. This keeps everything up to date. 2. git-friendly.

I wonder how they are doing it? simply re-evaluating every cell?
Post reply on HN