Skip to content

Basthon on the command line ​

Basthon leaves the browser: the basthon command runs its kernels in a terminal, with Node.js (version 20.15 or later). It is installed with npm:

bash
npm install -g @basthon/kernel-node

It is used like the python command: basthon program.py runs a file, basthon -c "print(6 * 7)" a statement, and basthon alone opens an interactive console, with completion and input(). It is exactly Basthon's Python, with its modules, and it reads and writes the files of the computer directly.

All of Basthon's languages are in, chosen from the extension of the file or with the --kernel option: SQL, OCaml, JavaScript, XCAS, C and R.

bash
basthon hello.c         # calls main and returns its exit code
basthon fact.ml         # OCaml
basthon --kernel sql    # an SQL console

Graphical outputs are not forgotten: matplotlib figures, tkinter windows, R charts, OCaml or JavaScript canvases open in a page of the browser and stay interactive. The program ends when this page is closed. With --no-browser, the images, SVG and HTML shown are simply saved in a directory.

Handy to test an activity before giving it to students, to run it in a script, or to mark a stack of papers: a --json mode even lets another program drive the kernel.