News for hackers. Stuff that matters.
Re:Pluto.jl – a reactive, lightweight, simple notebook by benhurmarcel on Friday August 28, 2020 @10:50AM (#24305553)
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.

Re:Pluto.jl – a reactive, lightweight, simple notebook by darsnack on Friday August 28, 2020 @11:35AM (#24306079)
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 by vanderZwan on Friday August 28, 2020 @11:22AM (#24305927)
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 by benhurmarcel on Saturday August 29, 2020 @08:47AM (#24315713)
Yes, that's the best explanation in the end I think. Maybe I'm too used to reuse variables and that's a bad habit I should work on. For example most of my counters are called i.
Re:Pluto.jl – a reactive, lightweight, simple notebook by 3JPLW on Friday August 28, 2020 @11:01AM (#24305696)
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 by ziotom78 on Friday August 28, 2020 @02:26PM (#24308348)
Exactly. It requires a change in mindset wrt Jupyter, but it is totally worth it!