Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ disableKinds = ['taxonomy', 'term', 'rss', 'sitemap', '404']
name = "notebook"
kind = "kernel · command"
href = "https://github.com/go-notebook/notebook"
blurb = "The kernel, the <code>notebook</code> command (<code>run</code>, <code>html</code>, <code>watch</code>, <code>serve</code>, <code>irb</code>) and the HTML export: <code>format</code> parses the Markdown, <code>analysis</code> builds the dependency graph from the syntax, <code>gen</code> writes the Go program, <code>kernel</code> compiles and drives it through <code>runtime</code> and keeps results and values, <code>export</code> writes the page. <strong>Ruby cells</strong> (<code>```ruby</code>) run on <a href=\"https://github.com/go-embedded-ruby/ruby\">rbgo</a>, a Ruby written in Go, with the <a href=\"https://github.com/go-scikit/ruby\">go-scikit bindings</a> (<code>Stats</code>, <code>Special</code>, <code>Optimize</code>, <code>Integrate</code>, <code>DataFrame</code>, <code>Plot</code>, <code>NDArray</code>), and share their variables with the Go cells. <code>--timeout</code> and <code>--memory</code> stop a runaway cell in either language. <strong><code>notebook irb</code></strong> is the same Ruby as an interactive session, as irb: <code>=&gt; inspect</code> after each input, <code>_</code>, multi-line input decided by rbgo's parser, Tab completion and history in a pure-Go line editor (<a href=\"https://github.com/go-ruby-reline/reline\">go-ruby-reline</a>), each input in a worker that <code>--timeout</code>, <code>--memory</code> or Ctrl-C can stop without losing the prompt, and <code>--save</code> to keep the session as a notebook. <a href=\"/docs/main/irb/\">More →</a> <strong>Julia cells</strong> (<code>```julia</code>) are parsed with <a href=\"https://github.com/go-embedded-julia/julia\">go-embedded-julia</a>'s parser and checked (syntax errors at their line with julia's message, names in the dependency graph under Julia's scope rules), and, since go-notebook v0.18.0, run by its interpreter (v0.15.0) in one kernel shared by the Julia cells: a global or a function a cell defines is there in the next one, and a failure is julia's own text. The kernel boots from a prebuilt Base image, fetched on the first Julia cell and loaded only if its SHA-256 is the pinned one (cold start about a second). A cell may run 30 s and 50 million statements, within a memory budget of 512 MiB counted as 16 bytes per array element (a floor, not the heap: strings are not counted, and one array may have at most 2^24 elements). Julia variables stay in Julia, as R's do: they are not shared with Go, Ruby, R, C or Fortran cells in either direction yet. Known limitations: a loop at the top level of a cell cannot update a global (go-embedded-julia#54). The playground checks Julia cells and does not run them (<em>Julia cells run in go-notebook, not yet in the browser</em>). <a href=\"/docs/main/julia/\">More →</a> <strong>R cells</strong> (<code>```r</code>) are parsed with <a href=\"https://github.com/go-embedded-r/r\">go-embedded-r</a>'s parser, identical to R 4.6.2 on R's own sources, and checked in the same way: syntax errors at their line in R's words, names in the graph, and a cell that cannot be analysed from its text (<code>&lt;&lt;-</code>, <code>eval</code>, <code>library</code>) depending on every cell above it. They run on go-embedded-r's evaluator in one shared environment (v0.10.0), and since v0.12.0 each cell is bounded: 512 MiB of vectors, 50 million steps, 30 s. The browser playground runs them too (playground v0.15.0), in its second core, with R variables kept apart from the other languages: 512 MiB, 20 million steps, 10 s per cell, and a crash restarts the core with a message on the cell. <a href=\"/docs/main/r/\">More →</a> <strong>Fortran cells</strong> (<code>```fortran</code>) are checked and run with <a href=\"https://github.com/go-embedded-fortran/fortran\">go-embedded-fortran</a> (since go-notebook v0.17.0, go-embedded-fortran v0.17.0: its <code>sema</code> session for the names and errors, its <code>eval.Session</code> for the running; free form, implicit typing off) and highlighted with go-rouge's <code>fortran</code> lexer. The Fortran cells share one session: a cell sees the variables (with the values the earlier cells left), procedures, modules and derived types of the Fortran cells before it. Fortran variables stay in Fortran, as R's do: they are not shared with Go, Ruby, Julia, R or C cells in either direction yet. A cell may make at most 2^32 loop iterations and calls and run 30 s, and a failure is reported at its line and column. The playground does not link the Fortran runtime yet. <a href=\"/docs/main/fortran/\">More →</a>"
blurb = "The kernel, the <code>notebook</code> command (<code>run</code>, <code>html</code>, <code>watch</code>, <code>serve</code>, <code>irb</code>) and the HTML export: <code>format</code> parses the Markdown, <code>analysis</code> builds the dependency graph from the syntax, <code>gen</code> writes the Go program, <code>kernel</code> compiles and drives it through <code>runtime</code> and keeps results and values, <code>export</code> writes the page. <strong>Ruby cells</strong> (<code>```ruby</code>) run on <a href=\"https://github.com/go-embedded-ruby/ruby\">rbgo</a>, a Ruby written in Go, with the <a href=\"https://github.com/go-scikit/ruby\">go-scikit bindings</a> (<code>Stats</code>, <code>Special</code>, <code>Optimize</code>, <code>Integrate</code>, <code>DataFrame</code>, <code>Plot</code>, <code>NDArray</code>), and share their variables with the Go cells. <code>--timeout</code> and <code>--memory</code> stop a runaway cell in either language. <strong><code>notebook irb</code></strong> is the same Ruby as an interactive session, as irb: <code>=&gt; inspect</code> after each input, <code>_</code>, multi-line input decided by rbgo's parser, Tab completion and history in a pure-Go line editor (<a href=\"https://github.com/go-ruby-reline/reline\">go-ruby-reline</a>), each input in a worker that <code>--timeout</code>, <code>--memory</code> or Ctrl-C can stop without losing the prompt, and <code>--save</code> to keep the session as a notebook. <a href=\"/docs/main/irb/\">More →</a> <strong>Julia cells</strong> (<code>```julia</code>) are parsed with <a href=\"https://github.com/go-embedded-julia/julia\">go-embedded-julia</a>'s parser and checked (syntax errors at their line with julia's message, names in the dependency graph under Julia's scope rules), and, since go-notebook v0.18.0, run by its interpreter (v0.15.0) in one kernel shared by the Julia cells: a global or a function a cell defines is there in the next one, and a failure is julia's own text. The kernel boots from a prebuilt Base image, fetched on the first Julia cell and loaded only if its SHA-256 is the pinned one (cold start about a second). A cell may run 30 s and 50 million statements, within a memory budget of 512 MiB counted as 16 bytes per array element (a floor, not the heap: strings are not counted, and one array may have at most 2^24 elements). Julia variables stay in Julia, as R's do: they are not shared with Go, Ruby, R, C or Fortran cells in either direction yet. Known limitations: a loop at the top level of a cell cannot update a global (go-embedded-julia#54). The playground checks Julia cells and does not run them (<em>Julia cells run in go-notebook, not yet in the browser</em>). <a href=\"/docs/main/julia/\">More →</a> <strong>R cells</strong> (<code>```r</code>) are parsed with <a href=\"https://github.com/go-embedded-r/r\">go-embedded-r</a>'s parser, identical to R 4.6.2 on R's own sources, and checked in the same way: syntax errors at their line in R's words, names in the graph, and a cell that cannot be analysed from its text (<code>&lt;&lt;-</code>, <code>eval</code>, <code>library</code>) depending on every cell above it. They run on go-embedded-r's evaluator in one shared environment (v0.10.0), and since v0.12.0 each cell is bounded: 512 MiB of vectors, 50 million steps, 30 s. The browser playground runs them too (playground v0.15.0), in its second core, with R variables kept apart from the other languages: 512 MiB, 20 million steps, 10 s per cell, and a crash restarts the core with a message on the cell. <a href=\"/docs/main/r/\">More →</a> <strong>Fortran cells</strong> (<code>```fortran</code>) are checked and run with <a href=\"https://github.com/go-embedded-fortran/fortran\">go-embedded-fortran</a> (since go-notebook v0.17.0, go-embedded-fortran v0.17.0: its <code>sema</code> session for the names and errors, its <code>eval.Session</code> for the running; free form, implicit typing off) and highlighted with go-rouge's <code>fortran</code> lexer. The Fortran cells share one session: a cell sees the variables (with the values the earlier cells left), procedures, modules and derived types of the Fortran cells before it. Fortran variables stay in Fortran, as R's do: they are not shared with Go, Ruby, Julia, R or C cells in either direction yet. A cell may make at most 2^32 loop iterations and calls and run 30 s, and a failure is reported at its line and column. The browser playground runs them too (playground v0.16.0), in its second core, with Fortran variables kept apart from the other languages: 200 million steps and 10 s per cell, and an endless <code>do</code> ends with a message and leaves the page usable. <a href=\"/docs/main/fortran/\">More →</a>"
[[params.repos]]
name = "playground"
kind = "wasm · page"
Expand Down
2 changes: 1 addition & 1 deletion playground/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/go-notebook/go-notebook.github.io/playground

go 1.27.3

require github.com/go-notebook/playground v0.15.0
require github.com/go-notebook/playground v0.16.0

require (
filippo.io/age v1.3.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions playground/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ github.com/go-nokogiri/nokogiri v0.1.0 h1:3Q3BewGHK16Bt34ggJeyf9xeIMJyA3dmfbIxAR
github.com/go-nokogiri/nokogiri v0.1.0/go.mod h1:zjghooYIK8Xfg+fL4/OUhROslx51xGsM3JKtB2TI0tg=
github.com/go-notebook/notebook v0.18.0 h1:D+dUbO7UGntilJgKy0RSe4c8lSM/29L5ATJsGh3vlaQ=
github.com/go-notebook/notebook v0.18.0/go.mod h1:uGGg7forGdvyhc3ohmknC/1mNf3FD7JkEmwj3yAx4s0=
github.com/go-notebook/playground v0.15.0 h1:298KCfPMBsOrpyJvu1OCILN010+snjfCF80MtWrNHAg=
github.com/go-notebook/playground v0.15.0/go.mod h1:n9jKYN6FtJjfP8llbctGgJaHtTykQf4uB+kge7IYyCA=
github.com/go-notebook/playground v0.16.0 h1:XewbwFXAxR/HPvdT6o/gK8Xp+SLVabqz2gI8sf+9fis=
github.com/go-notebook/playground v0.16.0/go.mod h1:n9jKYN6FtJjfP8llbctGgJaHtTykQf4uB+kge7IYyCA=
github.com/go-numerics/integrate v0.2.0 h1:IkJhDimTc7nQETCixEvbbHhtOF36GbANBKJI3mJB3Kw=
github.com/go-numerics/integrate v0.2.0/go.mod h1:ABjpcWy8ZSOg8j6S+7YRsvMJ2LpVkH4E64/CGet2gCw=
github.com/go-numerics/optimize v0.3.1 h1:eYkT9BpORKSwXnDtEJxXfZ19qJT0cI2RH6xEL3VLZSU=
Expand Down
35 changes: 35 additions & 0 deletions playground/notebooks/7-fortran.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fortran cells, run in your browser

A cell written in a `fortran` fence **runs** here, with [go-embedded-fortran](https://go-embedded-fortran.github.io/)'s evaluator compiled to WebAssembly. There is no `gfortran` behind it, and no server. The badge on the cell says **Fortran**, and the output is what the program prints.

A Fortran cell is a piece of a program, and what it declares stays: variables, procedures, modules and derived types persist from one Fortran cell to the next. This cell declares some data and a function:

```fortran
integer :: i, total
integer :: squares(10)

do i = 1, 10
squares(i) = i * i
end do
```

The next Fortran cell reads them. `print *` writes where Fortran's list-directed output goes:

```fortran
total = sum(squares)
print *, total
print *, 'mean of the squares:', real(total) / 10.0
```

Fortran's variables **stay Fortran's**, as in go-notebook: they do not cross to the Go cells, and the Go cells' variables do not cross to Fortran. This Go cell has its own `total`, and the Fortran cell above is not touched by it:

```go
total := 42
total
```

## Limits

A browser tab must not freeze, so a Fortran cell is bounded: 200 million loop iterations and procedure calls, and 10 seconds. A cell that goes past one is stopped with a message that says which, and the page stays usable: `do` with no exit ends on the step limit. The evaluator has no access to a file or an environment variable of your machine.

Follow the progress of the evaluator at [go-embedded-fortran.github.io](https://go-embedded-fortran.github.io/).
Loading