Bottom-up in Pluto?

I just noticed that Pluto notebooks are built up bottom to top. Or, rather, the top is at the bottom, if saying it like this makes sense.

I am hesitant to call this “wrong”, even though it did seem pretty strange to me. What I’d like to ask: what is your experience with it? Does it make understanding the notebook easier? Or harder? And, if you happen to know this: why is it this way?

1 Like

Are you referring to the fact that output is above code? If yes, FWIW, there was a discussion in this issue about that.

Not only that. For instance, in this presentation the code is added to the document at the top.

Oh I see. Well, then it’s not really bottom-up. Instead, if I understand correctly, it’s that you can move your cells in the order you want, while the order in which cells are run is determined under the hood.

You can add cells below or above, as you wish:

order1

and you can rearrange by dragging cells around, too:

order2

[EDIT] Note you can check the order in which cells are executed in the .jl file, which is a standard Julia script, although it has extra metadata for Pluto (including the order in which the cells appear in the Pluto interface).

3 Likes

Well, that sounds like a recipe for creating quite a bit of confusion, I’d say.

1 Like

I understand the feeling but, IMHO, on the contrary, the reactivity and the fact that there is no hidden state in Pluto notebooks means that you are less likely to be confused by the output of cells.

BTW, you can do similar reorderings in Jupyter:

Jupyterlab1

and with a little more work, go the bottom-up way:

jupyterlab2

[EDIT] @PetrKryslUCSD Maybe what you would like is a “order of execution” number appearing in front of each cell to tell you that order? @fonsp have you considered that? (Also pinging @fonsp because he probably has much better answers than mine to this thread)

6 Likes

Overall, I see this as a feature. Most of the time in a notebook, you’re presenting the results up-front, and then showing the derivation (dependent logic). I like @briochemc’s suggestion that having some sort of numbering; although I’d do it on the variables mentioned. For example, one could use , , etc. to mark each computation line, and then perhaps a way to refer to those lines in the text. Sometimes I when explaining a top-level calculation, one wishes to outline the parts of the expression that come from other spots. Perhaps even modifying the visualization of the statements themselves, using hyperlinked, superscript numbers/letters to mark definitions that are done from downstream? When the expression is edited, those markers go away; when shown in text they are unobtrusive but hyperlinked?

I think of a Pluto notebook not as a “notebook” (which is still firmly Jupyter in my mind) but rather more akin to an excel spreadsheet. It doesn’t matter where the cells are, the sheet is always consistent.

I find the “bottom up” paradigm helpful because the most compelling part of a notebook is almost always the last thing you do! Why not have that as your topline if order doesn’t matter?

2 Likes

I think of Pluto as providing a cell-based reactive functional environment, and spreadsheets as grid-based reactive functional environments. For years I wanted something that combined Python’s expressiveness with Excel’s speed-to-first-results and instant-execution-on-modification. Pluto really scratches that itch.

My Pluto notebooks tend to have a mix of markdown cells with explanatory text, input cells (if there are knobs to be turned) and resulting plots or tables in the top, and most code is shoved lower (much like I would have done with a spreadsheet) and I’ve used it that way to present results and have sent them to coworkers by using the static html export.

Note that Pluto is not compatible with all of Julia. It works by looking at assignments in the cells to build a dependency graph so it can get confused by macros that hide assignments and it can’t track mutation. The macro issues will get improved but I suspect the other will remain as a limitation. This means one should adopt a functional-style between cells and only use mutation within cells, but I find this to be a pretty natural style of working.

3 Likes