Skip to content

Notebook ​

Romain CasatiOctober 17, 2026· in OCaml, Notebook, Console, New modules· 1 min read

Big integers and rationals in OCaml with zarith ​

In Basthon, OCaml is compiled to JavaScript and its integers are 32 bits: max_int is 2,147,483,647 and the factorial of 13 already overflows. The zarith library brings integers of arbitrary size (Z module) and exact rationals (Q module):

ocaml
#require "zarith";;

let rec fact n = if n = 0 then Z.one else Z.mul (Z.of_int n) (fact (n - 1));;
fact 100;;

Z.probab_prime Z.(~$2 ** 127 - ~$1) 25;;
Q.(of_ints 1 10 + of_ints 2 10);;

GCD and Bézout's identity, modular inverse and exponentiation, primality tests: everything is there for arithmetic, up to a miniature RSA written in a few lines in the example notebook. Values are shown directly in the toplevel, and computations stay fast thanks to JavaScript's big integers (BigInt).

Play with it!

A miniature RSA with zarith


Romain CasatiOctober 17, 2026· in Python, Console, Notebook· 1 min read

Express restarts for Python ​

Restarting Basthon's Python kernel is now almost instant: about half a second, against three seconds before. You can start again from a clean state as often as needed, without waiting, in the console as in the notebook.

To achieve it, Basthon takes a snapshot of Python's memory just after it is loaded, before running a single line of code. At each restart, it starts again from this snapshot instead of reloading everything. Nothing of your code or your variables is in it: the kernel really restarts afresh.

The browser also keeps this snapshot from one visit to the next. From the second visit on, the kernel is ready in less than a second, instead of two and a half.

These speed-ups concern the isolated kernels, used by default. The legacy mode starts as before.


Romain CasatiOctober 16, 2026· in R, Notebook, Console· 1 min read

An R kernel in Basthon ​

After C, a new language arrives in Basthon: R! The reference language of statistics now works directly in the browser, with no installation nor server, thanks to the webR project.

Everything you expect from R is there:

  • results are shown as in the R console;
  • charts (plot, hist, barplot…) appear directly next to the console or below the cell;
  • missing packages (dplyr, ggplot2…) are downloaded automatically at the first library();
  • the help is still available with ?mean or help("mean");
  • readline() asks the user for an input.

It is available in the console and in the notebook, and the gallery already offers a few examples.

Play with it!

The R kernel in the console


Romain CasatiOctober 14, 2026· in Notebook· 1 min read

The notebook speaks ten languages ​

The interface of Basthon's notebook is now translated into ten languages: French, English, German, Spanish, Italian, Dutch, Portuguese, Russian, Chinese and Japanese.

The language is chosen in the View menu, Language submenu, and the choice is remembered for the next visits. It can also be forced in a link with the lang parameter, for instance ?lang=en.

Play with it!

The notebook in German


Romain CasatiOctober 14, 2026· in C, Notebook, Console· 1 min read

A C kernel in Basthon ​

Big news: Basthon now speaks C! The code is compiled to WebAssembly directly in the browser, with no installation nor server, thanks to the xcc compiler.

The kernel is designed for learning:

  • no need for main: statements run directly, and everything declared stays available for what follows;
  • the last expression, without a semicolon, is shown with its type;
  • scanf works like Python's input;
  • the formats of printf and scanf, NULL pointers and array overflows are reported.

It is available in the console and in the notebook.

Play with it!

The C kernel in the console