Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jnb

jnb brings the J language to notebooks: a %%j cell magic and %j line magic for Jupyter and IPython, and a real Jupyter kernel. J runs in-process through libj, the engine library that ships with every J install, so there is no separate process or protocol to manage.

Installation

Install J: pip install jlanguage, or install it from jsoftware.com – jnb finds either. Then:

pip install jnb

To register the magics with every IPython and Jupyter session automatically, run in your terminal:

jnb_install

The J session only starts the first time you run a magic, so having jnb installed everywhere costs nothing when you don’t use it. To install the Jupyter kernel: python -m jnb.jkernel install.

The j magics

%%j runs code in a persistent J session and displays its output verbatim; %j expr returns an expression’s value as a Python object. The session keeps nouns and verbs across cells:

%%j
m =: 3 3 $ i. 9
m +/ . * m
15 18  21
42 54  66
69 90 111
z = %j m
z
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]

Under the hood there’s no separate process or protocol: jnb loads libj via ctypes, so completion, errors, and interrupts come straight from the engine’s C API. Call the J session class to run code, move values in both directions with [], and lift verbs into Python callables with fn – see j for the full walkthrough.

The J Jupyter kernel

jnb ships jkernel, a real Jupyter kernel for J built on kernmini: any Jupyter client (JupyterLab, nbclient, jupygate, and LLM agents through clikernel) can execute J with workspace state persisting across cells, stream session output live, and interrupt a long computation with a J attention interrupt while keeping the workspace. python -m jnb.jkernel install registers the kernelspec.

On startup the kernel runs ~/.config/jnb/startup.ijs (if it exists) in the session.

Limitations

  • %j transfers values through the engine’s typed-array API, so it’s limited to booleans, integers, floats, and characters; boxed, extended, and rational values raise (display them with %%j instead).
  • Windows isn’t supported yet: the libj binding is untested there. macOS and Linux are supported.

Learning J

Start with Learning J and the J wiki, whose NuVoc page is the reference for every primitive.

About

The J language in notebooks, with j magics for IPython and Jupyter and a kernmini-based J kernel

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages