Giter Club home page Giter Club logo

pluto.jl's Introduction

🎈 Pluto – introduction (20 min) at Juliacon 2020 🎈


🌐 Pluto – one year later (25 min) at Juliacon 2021 🌐


πŸͺ Pluto – reactive and reproducible (25 min) at JupyterCon 2023 πŸͺ


Pluto.jl

Writing a notebook is not just about writing the final document β€” Pluto empowers the experiments and discoveries that are essential to getting there.

Explore models and share results in a notebook that is

  • reactive - when changing a function or variable, Pluto automatically updates all affected cells.
  • lightweight - Pluto is written in pure Julia and is easy to install.
  • simple - no hidden workspace state; friendly UI.

reactivity screencap

🎈 Pluto demo inside your browser 🎈

Input

A Pluto notebook is made up of small blocks of Julia code (cells) and together they form a reactive notebook. When you change a variable, Pluto automatically re-runs the cells that refer to it. Cells can even be placed in arbitrary order - intelligent syntax analysis figures out the dependencies between them and takes care of execution.

Cells can contain arbitrary Julia code, and you can use external libraries. There are no code rewrites or wrappers, Pluto just looks at your code once before evaluation.

Output

Your notebooks are saved as pure Julia files (sample), which you can then import as if you had been programming in a regular editor all along. You can also export your notebook with cell outputs as attractive HTML and PDF documents. By reordering cells and hiding code, you have full control over how you tell your story.


Dynamic environment

Pluto offers an environment where changed code takes effect instantly and where deleted code leaves no trace. Unlike Jupyter or Matlab, there is no mutable workspace, but rather, an important guarantee:

At any instant, the program state is completely described by the code you see.
No hidden state, no hidden bugs.

Interactivity

Your programming environment becomes interactive by splitting your code into multiple cells! Changing one cell instantly shows effects on all other cells, giving you a fast and fun way to experiment with your model.

In the example below, changing the parameter A and running the first cell will directly re-evaluate the second cell and display the new plot.

plotting screencap


Built-in package manager

Pluto uses syntax analysis to understand which packages are being used in a notebook, and it automatically manages a package environment for your notebook. You no longer need to install packages, you can directly import any registered package like Plots or DataFrames and use it.

To ensure reproducibility, the information to exactly reproduce the package environment is stored in your notebook file. When someone else opens your notebook with Pluto, the exact same package environment will be used, and packages will work on their computer, automatically! more info

package manager screencap


HTML interaction

Lastly, here's one more feature: Pluto notebooks have a @bind macro to create a live bond between an HTML object and a Julia variable. Combined with reactivity, this is a very powerful tool!

@bind macro screencap


You don't need to know HTML to use it! The PlutoUI package contains basic inputs like sliders and buttons. Pluto's interactivity is very easy to use, you will learn more from the featured notebooks inside Pluto!

But for those who want to dive deeper - you can use HTML, JavaScript and CSS to write your own widgets! Custom update events can be fired by dispatching a new CustomEvent("input"), making it compatible with the viewof operator of observablehq. Have a look at the JavaScript featured notebook inside Pluto!


Pluto for teaching

Pluto was developed alongside the free online course Introduction to Computational Thinking at MIT, with the goal of creating a programming environment that is powerful, helpful and interactive, without being too intimidating for students and teachers.

Are you interested in using Pluto for your class? Here are some presentations by people who are using it already: the MIT team, Gerhard Dorn, Daniel Molina, Henki W. Ashadi and Max KΓΆhler.

Seam.carving.interactive.mp4

(video) Grant Sanderson (3Blue1Brown) using Pluto's interactivity to teach Computational Thinking at MIT!




Let's do it!

Ingredients

For one tasty notebook πŸ₯ž you will need:

Installation

🎈 How to install Julia & Pluto (6 min) 🎈

Run Julia, enter ] to bring up Julia's package manager, and add the Pluto package:

julia> ]
(v1.10) pkg> add Pluto

Press Ctrl+C to return to the julia> prompt.

Usage

To run Pluto, run the following commands in your Julia REPL:

julia> import Pluto
julia> Pluto.run()

Pluto will open in your browser, and you can get started!

Questions and Help

Questions? Have a look at the FAQ.


Interested in learning Julia, Pluto and applied mathematics? Join the open MIT course taught by Alan Edelman, David P. Sanders & Grant Sanderson (3blue1brown) (and a bit of me): Introduction to Computational Thinking, Spring 2021.


Contribute to Pluto

Follow these instructions to start working on the package.

License

Pluto.jl is open source! Specifically, it is MIT Licensed. Pluto.jl is built by gluing together open source software:

If you want to reference Pluto.jl in scientific writing, you can use our DOI: DOI

Featured notebooks

Unless otherwise specified, the included featured notebooks have a more permissive license: the Unlicense. This means that you can use them however you like - you do not need to credit us!

Your notebook files are yours, you also do not need to credit us. Have fun!

From the authors

The Pluto project is an ambition to rethink what a programming environment should be. We believe that scientific computing can be a lot simpler and more accessible. If you feel the same, give Pluto a try! We would love to hear what you think. 😊

You can chat with us

feedback screencap

Questions? Have a look at the FAQ.

Sponsors

Development of Pluto.jl is partially sponsored by

MIT logo The free online course Introduction to Computational Thinking at MIT uses Pluto notebooks to teach scientific computing in a new way. Homeworks react to the student in realtime, with live answer checks and visualizations while you solve problems.
QuEra logo QuEra Computing uses a Pluto notebook as an online dashboard to control their quantum computer!
JuliaHub logo JuliaHub enables the creation and editing of Pluto notebooks on the cloud!
NumFOCUS logo The mission of NumFOCUS is to promote open practices in research, data, and scientific computing by serving as a fiscal sponsor for open source projects and organizing community-driven educational programs.

Created by Fons van der Plas and MikoΕ‚aj Bochenski. Inspired by Observable.

pluto.jl's People

Contributors

aviatesk avatar ciaranomara avatar ctrekker avatar dependabot[bot] avatar disberd avatar dralletje avatar ekzhang avatar fonsp avatar github-actions[bot] avatar hirumalpriyashan avatar iboss-ptk avatar icweaver avatar jeremiahpslewis avatar kcin96 avatar lucifer1004 avatar luis-mueller avatar lungben avatar malyvsen avatar michaelhatherly avatar moelf avatar novoselrok avatar pangoraw avatar pankgeorg avatar pocket-titan avatar rikhuijzer avatar roger-luo avatar schneiderfelipe avatar tecosaur avatar vladflore avatar zmoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pluto.jl's Issues

Frontend config

Would be very cool if this is done within the reactive environment! I imagine:

there is a yellow cell, before all other cells (which is hidden by default), and whatever the output of that cell is will be used as config Dict by Saturn. Like:

Dict(:interactivearrays => false, 
     :theme => "body: {font-family: 'Comic Sans MS' !important;}")

Something very cool is that this cell can also be reactive! Like:

if @__FILE__ == "bigdata.jl"
    Dict(:theme => read("~/bigdatatheme.css", String))
else
    Dict()
end

Needs a config file

Move function reactivity from definition to call

Currently, function definitions are considered dependent on the variables and functions that are referenced in them, and function calls are considered dependent on definitions.
This breaks when a() calls b(), and b() calls a() - even though this double recursion is not paradigmatically illegal.

We should instead consider function calls dependent on the variables and functions referenced in the function definition. This will also solve the problem of reactivity in response to modifying global variables within functions.

Visualize cell reactive dependencies

Suggestion:
When focused on a cell, all cells that reference that cell get highlighted. (Either with depth 1, or with full depth.) This makes it easy to see what reevaluating the cell will do.

Vice versa might also be useful.

Reactive response to removing `using Module`

If a Module exports some variables, those will be brought into the workspace when a using Module call is somewhere, and they will disappear when the using call is gone.

However, removing a using Module does not reactively reevaluate cells that depend on its exported variables. Those cells need manual reevalutaion.

Requires Pluto to know exports.

Clear browser support

Decide which ones to support, and nudge users of other browsers to switch to firefox.

File I/O

One of the reasons to write a notebook system from scratch is to change the default file format. Our wishes are:

  • Output is saved separately, optionally.
  • The file has nothing but legal Julia syntax.
  • The file must be readable in plain form.
  • Notebooks are git merge-friendly. This includes:
    • Minimal changes in code are minimal diffs.
    • A merge conflict where two people added a cell can be merged automatically.
  • The file should not change when you:
    • Open the file, run cells, save and close the file.
  • If your notebook runs without errors on "Run all", it should run when you do julia mynotebook.jl
    • You should be able to include("./yournotebook.jl") in another script/notebook, and use the globally defined variables and functions.
    • This creates a problem with arbitrary cell order.
  • Cells that are disconnected dependency-wise, should keep their order.
  • Any legal Julia script can be interpreted as a Pluto notebook.

Bug when changing double assignment to a reference

To recreate:
add two cells with

x = 1
x = 2

then change one of the cells to

x

and evaluate

image

(note the empty error message)

evaluating the cell x a second time (without change) gives:

image

Evaluating the cell x = 1 fixes all errors.

Rename notebook file UI

A way to change the path of a running notebook.

I suggest that this will move the file, not copy it.

Needs to report to the user whether the path is legal, and prompt whether they want to override.

Query-response system for client js

Right now the client can send requests to Pluto:
send("completepath", {query: "/home/f"})

The server will quickly respond, and the response message is handled by editor.js/onUpdate. However, it would be nicer if the control flow was not lost, and you could do:

sendreceive("completepath", {
    query: "/home/f",
}).then((update) => {
   ...
}).catch(console.error)

To do so, requests just need a unique ID, and client.js can handle all the Promises.

Testing!

If #8 is done then this would be much easier!

Multiple outputs and inputs per cell

A cell input like:

πŸ• = 1
πŸ₯ž = 2

should not be legal, because it is not a single expression. This might be unexpected (and part of the learning curve) for new users, and we could accept it without breaking the paradigm by:

  • Splitting up the expression into two cells.
  • Giving the cell two outputs, which are stacked on top of each other with a clear division between them.

A nice hybrid solution is to do the first option, and to design the editor layout in such a way that all cells fluently follow each other. (If code is folded).

Note:
The cell

πŸ• = 1; πŸ₯ž = 2

which is syntactic sugar for

begin
    πŸ• = 1
    πŸ₯ž = 2
end

is a single expression, which is not an assignment, but an evaluation that performs two global assignments. Parsing this cell should be legal (as a single expression), but running it might give an error (depending on what we decide to do with globals).

Package management is broken

Because of the moving workspaces, you have to use import instead of using. Also, all workspaces live inside Pluto.ModuleManager, so they can't use packages that you added to your environment. (Pluto has its environment separate from the one you started the REPL in.)

Things exported by a package, from using, don't show up in names:

julia> using Plots

julia> plot
plot (generic function with 3 methods)

julia> names(@__MODULE__, all=true, imported=true)
9-element Array{Symbol,1}:
 Symbol("##1#2")
 :Base
 :Core
 :InteractiveUtils
 :Main
 :Plots
 :ans
 :eval
 :include

Multiple notebook support

We almost have it already, but we still need:

  • List of running notebooks in UI
  • A way to stop a running notebook
  • A separate workspace module for each notebook

FAQ

With a link from the Pluto page.

Let's do Github Pages for now without Documenter.jl? The documentation is mostly about using the UI, not about interfacing with Pluto from another julia program.

In-game file browser

Right now we have a text input box where you can paste the full path of your notebook file. Instead, we should have a file browser inside the web interface.

The ideal solution would be the built-in "Open file" dialog, but browser security prevents us from getting the path of the selected file, which we need for autosave.

This means that we need to implement a WebSocket response for file queries, and design UI to browse files (no usable solution exists for this yet).

DOM interaction mechanism

A way to define a cell like:

t = Saturn.animated(5fps, :loop, 1:100)

Restarts when (reactively) reevaluated.

but what about multiple animators in one notebook? using the same fps for all makes sense.

Stop execution

Jupyter can't stop everything, but the REPL can. Let's try to make it like the REPL!

Autocomplete

Let's do this thing!

CodeMirror side - options:

Julia side - options:

  • look at how the REPL does it - lightweight option
  • integrate the microsoft Language Server Protocol (used by VS Code, Atom and some others) - feature complete option
  • run the LSP implementation from Juno or VS Code without using the LSP - maybe the easier option

WebSockets can break after computer in hibernation

I've seen this a few times - when I leave Pluto running overnight, and put my computer in hibernate (i think?), the WebSocket communication is broken.

On the client side:
HTTP requests work fine. Opening a new notebook (with new UUID) still works.
The socket is openened, but no messages are received. I can send (bad) messages without closing the socket.

On the server side:
There are no errors in Pluto, not even for bad messages or closing the socket. Last night's sockets closed, and this error was thrown in Pluto.jl:457.

system: Windows 10, pluto running on Julia v1.0 in Legacy WSL Ubuntu 18

Export HTML with baked bonds

Ability to export to HTML that has all @bond interactions baked. The output for each combination of inputs will be stored inside the document, in an efficient way.

This way, you would have an interactive document that works offline, without a running Julia instance.

Better error: multiple defs for function

Multiple defintions for a variable should be illegal, but writing different specialised versions of the same function - in different cells - should be legal.

For now, the multiple def error for functions should advise the user to put all function defs in the same cell, inside a begin block.

Better error: multiple expressions per cell

Insteaf of "unexpected ... after expression", it should detect that the cell contains multiple valid expressions, and advise the user to wrap cells in a begin/let block.

Or we solve #7 - multiple outputs per cell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.