# \[ANN\] ExpressionExplorer.jl and PlutoDependencyExplorer.jl – the internal reactivity algorithm of Pluto!

**URL:** <https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068>\
**Category:** Package Announcements\
**Tags:** package, announcement, reactiveprogramming, pluto\
**Created:** [January 21, 2024, 10:52am UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068 "2024-01-21T10:52:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [January 21, 2024, 10:52am UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/1 "2024-01-21T10:52:21Z")

</div>

We just released **two new packages**! 🎉

- [ExpressionExplorer.jl](https://github.com/JuliaPluto/ExpressionExplorer.jl) (EE) – find all variables assigned and referenced in a piece of code.
- [PlutoDependencyExplorer.jl](https://github.com/JuliaPluto/PlutoDependencyExplorer.jl) (PDE) – sort a list of codes by execution order

Both packages are quite small and load fast, with minimal dependencies. The packages were part of [Pluto’s](https://plutojl.org) source code, but we decided to release them separately so that they can be used in other projects!

# ExpressionExplorer

Find all variables _referenced_ and _defined_ in an expression. This package is used internally by Pluto to find links between cells.

### Quick example

```julia
julia> using ExpressionExplorer

julia> ex = :(const words = split(line));

julia> node = ExpressionExplorer.compute_reactive_node(ex);

julia> node.references
Set{Symbol} with 2 elements:
  :line
  :split

julia> node.definitions
Set{Symbol} with 1 element:
  :words

```

> _For more information, check out the documentation: [ExpressionExplorer.jl](https://github.com/JuliaPluto/ExpressionExplorer.jl#api)_

# PlutoDependencyExplorer

This package contains Pluto’s dependency sorting algorithm. Given a list of cell codes, PlutoDependencyExplorer can tell you in which order these cells should run. For example:

```julia
julia> import PlutoDependencyExplorer as PDE

julia> struct SimpleCell <: PDE.AbstractCell
           code
       end

julia> notebook = SimpleCell.([
           "x + y"
           "x = 1"
           "y = x + 2"
       ]);

julia> empty_topology = PDE.NotebookTopology{SimpleCell}();

julia> topology = PDE.updated_topology(
           empty_topology,
           notebook, notebook;
           get_code_str = c -> c.code,
           get_code_expr = c -> Meta.parse(c.code),
       );

julia> order = PDE.topological_order(topology);

julia> order.runnable
3-element Vector{SimpleCell}:
 SimpleCell("x = 1")
 SimpleCell("y = x + 2")
 SimpleCell("x + y")

```

> _For more information, check out the documentation: [PlutoDependencyExplorer.jl](https://plutojl.org/en/docs/plutodependencyexplorer/)_

# Which package should I use?

PlutoDependencyExplorer uses the low-level package ExpressionExplorer to find the assignments and references of each cell. PlutoDependencyExplorer uses this information to build a dependency graph between cells (i.e. a `NotebookTopology`), which can be used to find the order to run them in (a `TopologicalOrder`).

If you are interested in **ordering a list of expressions** in execution order (the order that Pluto runs cells in), then use PlutoDependencyExplorer. If you just want to know which variables are assigned or referenced in a **single expression** , use ExpressionExplorer.

# Let us know what you think!

We hope that these packages can be useful to the Julia community! Do you have any fun ideas? Or comments about the package? Let us know!

---

<div class="post-metadata">

**Author:** ![jdm204](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdm204/32/39289_2.png) [@jdm204](https://discourse.julialang.org/u/jdm204)\
**Post date:** [January 24, 2024, 3:33pm UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/2 "2024-01-24T15:33:59Z")

</div>

Very cool, thanks for this - I wonder if it could be used to implement a Pluto-like system for Julia in emacs…

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [January 26, 2024, 4:04am UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/3 "2024-01-26T04:04:50Z")

</div>

With a bit of work, yes. I expect based on the people I know interested in this and time/current projects that we’ll see a very high quality `ob-julia` in about 1-2y.

---

<div class="post-metadata">

**Author:** ![svilupp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/svilupp/32/34933_2.png) [@svilupp](https://discourse.julialang.org/u/svilupp)\
**Post date:** [January 26, 2024, 11:53am UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/4 "2024-01-26T11:53:11Z")

</div>

Thank you!!

This is amazing! I can think of several applications for GenAI/Agents to help them understand the code!

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [January 29, 2024, 5:37pm UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/5 "2024-01-29T17:37:01Z")

</div>

Nice! Please let us know if this package is useful or if something is unclear!

We always value feedback, not just bug reports!

---

<div class="post-metadata">

**Author:** ![svilupp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/svilupp/32/34933_2.png) [@svilupp](https://discourse.julialang.org/u/svilupp)\
**Post date:** [January 30, 2024, 7:46am UTC](https://discourse.julialang.org/t/ann-expressionexplorer-jl-and-plutodependencyexplorer-jl-the-internal-reactivity-algorithm-of-pluto/109068/6 "2024-01-30T07:46:11Z")

</div>

It was a great to help me clarify what I need + more robust than my simple solution written by GPT4.

But I had to hack around it to get the information I needed.

Would it be simpler to mention my use case here?
