diff --git a/hugo.toml b/hugo.toml index 163bcf8..fbc9d19 100644 --- a/hugo.toml +++ b/hugo.toml @@ -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 notebook command (run, html, watch, serve, irb) and the HTML export: format parses the Markdown, analysis builds the dependency graph from the syntax, gen writes the Go program, kernel compiles and drives it through runtime and keeps results and values, export writes the page. Ruby cells (```ruby) run on rbgo, a Ruby written in Go, with the go-scikit bindings (Stats, Special, Optimize, Integrate, DataFrame, Plot, NDArray), and share their variables with the Go cells. --timeout and --memory stop a runaway cell in either language. notebook irb is the same Ruby as an interactive session, as irb: => inspect after each input, _, multi-line input decided by rbgo's parser, Tab completion and history in a pure-Go line editor (go-ruby-reline), each input in a worker that --timeout, --memory or Ctrl-C can stop without losing the prompt, and --save to keep the session as a notebook. More → Julia cells (```julia) are parsed with go-embedded-julia'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 (Julia cells run in go-notebook, not yet in the browser). More → R cells (```r) are parsed with go-embedded-r'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 (<<-, eval, library) 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. More → Fortran cells (```fortran) are checked and run with go-embedded-fortran (since go-notebook v0.17.0, go-embedded-fortran v0.17.0: its sema session for the names and errors, its eval.Session for the running; free form, implicit typing off) and highlighted with go-rouge's fortran 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. More →" + blurb = "The kernel, the notebook command (run, html, watch, serve, irb) and the HTML export: format parses the Markdown, analysis builds the dependency graph from the syntax, gen writes the Go program, kernel compiles and drives it through runtime and keeps results and values, export writes the page. Ruby cells (```ruby) run on rbgo, a Ruby written in Go, with the go-scikit bindings (Stats, Special, Optimize, Integrate, DataFrame, Plot, NDArray), and share their variables with the Go cells. --timeout and --memory stop a runaway cell in either language. notebook irb is the same Ruby as an interactive session, as irb: => inspect after each input, _, multi-line input decided by rbgo's parser, Tab completion and history in a pure-Go line editor (go-ruby-reline), each input in a worker that --timeout, --memory or Ctrl-C can stop without losing the prompt, and --save to keep the session as a notebook. More → Julia cells (```julia) are parsed with go-embedded-julia'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 (Julia cells run in go-notebook, not yet in the browser). More → R cells (```r) are parsed with go-embedded-r'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 (<<-, eval, library) 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. More → Fortran cells (```fortran) are checked and run with go-embedded-fortran (since go-notebook v0.17.0, go-embedded-fortran v0.17.0: its sema session for the names and errors, its eval.Session for the running; free form, implicit typing off) and highlighted with go-rouge's fortran 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 do ends with a message and leaves the page usable. More →" [[params.repos]] name = "playground" kind = "wasm · page" diff --git a/playground/go.mod b/playground/go.mod index 7ad7b67..28d1317 100644 --- a/playground/go.mod +++ b/playground/go.mod @@ -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 diff --git a/playground/go.sum b/playground/go.sum index 460d239..026f7d2 100644 --- a/playground/go.sum +++ b/playground/go.sum @@ -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= diff --git a/playground/notebooks/7-fortran.md b/playground/notebooks/7-fortran.md new file mode 100644 index 0000000..3a5e94d --- /dev/null +++ b/playground/notebooks/7-fortran.md @@ -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/).