# oK is a JavaScript interpreter for a K5 dialect you can read in an afternoon

> oK is a toy interpreter for a dialect of the K array language, written in JavaScript and runnable as a browser REPL or a command line REPL. It is deliberately simple rather than fast, and its author says outright to expect bugs.

**JohnEarnest/ok** — An open-source interpreter for the K5 programming language.

- Repository: https://github.com/JohnEarnest/ok
- Stars: 654 · Forks: 78
- Language: JavaScript
- License: MIT
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/johnearnest-ok

## A dialect of K aimed at the still evolving K5 spec

oK is described as a toy interpreter for a dialect of the K programming language, and the specific target is stated: it aims to be an implementation of K5, the still evolving bleeding edge version of the language. K itself is an array language, and the interesting part of that lineage for a reader is that K arrived first as a commercial product, kdb from Kx Systems, with a free version available, and that Kona is an open source reimplementation of K3 and K4. The project points you at both, which tells you how it sees itself in the ecosystem. This is not a replacement for a commercial K and does not try to be. The author's framing is unusually blunt about quality. Expect oK to be buggy, incomplete and occasionally flat-out wrong, but slowly improving over time, and the manual is linked as the overview of the operators and syntax. The audience is a programmer who wants to understand how a terse array language works, and for that purpose a readable implementation in a familiar language beats a fast one.

## JavaScript was chosen for readability, not for speed

The implementation language choice is explained directly: JavaScript was chosen because it is familiar to many programmers and has first class functions. The project states that oK does not intend to be particularly fast or suitable for any practical purpose beyond learning, and instead emphasises simplicity of implementation. That is a coherent design position for an interpreter, because the interesting code in a language implementation is the evaluator and the data model, not the dispatch loop, and first class functions make it easy to write an evaluator in a functional style. The repository layout is small enough to read in a sitting. The top level contains oK.js as the main entry, repl.js for the command line REPL, test.js for the automated test run, convert.js, index.html and mobile.html for the browser and mobile clients, an ike/ directory, an examples/ directory, docs/ and a small package.json whose only script is start mapped to node repl.js. The examples directory is worth a look because it shows the language being used for real things: bencode, binpack, circle, donut, hangman, idioms, islands, key, lexicographic, merge, parsing, runlength, strings, tictac and treedepth.

## The browser REPL is the easiest way in

The easiest way to run oK is the browser based REPL, hosted as a static page, and the reason it is the recommended entry point is that it needs nothing installed. It also has a small set of special commands issued at the beginning of a line. A double backslash cancels the current multiline expression, \e toggles the scratchpad editor pane whose content is persisted via localstorage in case the browser crashes, \r runs the contents of that editor and shift+enter does the same with the editor focused, \c clears the output log, \t times the execution of the remainder of the line, \f lists all presently defined functions, \v lists all presently defined variables, and \u generates a code URL from the remainder of the line. That last one interacts with a URL parameter to make shareable programs. If you visit the page with a ?run= parameter, the remainder of the URL is URI decoded and executed, so a link can carry a whole expression. The documentation shows the pairing, with \u 1+2 producing a code URL pointing back at the page. The same trick combines with the monadic 0: verb, which reads a URL, so a link can load code from a pastebin or a gist and then run it. The caveat the documentation raises is the browser same-origin policy, which means the host of the fetched URL must send an Access-Control-Allow-Origin header, and GitHub gists will do.

## The IO verbs are where a K implementation gets its personality

oK provides several numbered IO verbs and they are the clearest window into how the language handles data. The dyadic 0: takes a symbol or a string as its left argument and writes the right argument to that destination as text, and in the browser REPL the symbol is ignored and output goes to the console, while in the command line REPL output goes to the file named by the left argument, or to stdout if that argument is empty. Monadic 0: reads the content of a file or a URL, and in the browser it performs a synchronous HTTP request and returns a tuple of the HTTP status code and the response, which the documentation pairs with loading code from elsewhere or accessing RESTful web APIs. In the command line REPL, 0: reads a file as text, returns a directory listing if the path is a directory, and if the path is empty and oK is not running interactively it reads text from stdin until it encounters a newline. Monadic 1: works the same way but expects a JSON response and attempts to parse it into a K data structure you can then manipulate, and the example in the documentation fetches a weather API and then extracts a field from the result. Monadic 5: returns a printable string representation of the right argument, as in K3, which is the debugging tool of choice.

## Running from the command line, and what the REPL there cannot do

The command line path runs oK with Node.js, and there are two entry points. test.js runs a series of automated tests:

```shell
	je@indigo$ node test.js
```

and repl.js starts the included REPL:

```shell
	je@indigo$ node repl.js 
```

The REPL is explicitly described as very simplistic compared to the CLI provided in a complete K interpreter, and it lacks interactive debugging facilities. You exit with a double backslash or by pressing Ctrl+D, and if you supply a filename as an argument the REPL executes that file instead:

```shell
	je@indigo$ node repl.js examples/hangman.k
```

Two practical notes are worth carrying over from the documentation. The first is about stdin. The release version of Node.js at the time of writing does not portably support blocking reads from stdin, and the REPL was tested with Node v0.11.14 on OSX, so the interactive experience depends on how your Node build handles stdin. The second is that the package manifest is minimal: the name is ok, the version is 0.0.0, the licence is MIT, the description is an open-source interpreter for the K5 programming language, the only script is start mapped to node repl.js, and the main entry is oK.js. There is no build step, no dependency list and no test framework in the manifest, which is consistent with an interpreter written from scratch in a single file.

## The mobile client turns the verb set into a keypad

There is a separate mobile page for phones, and it is a more interesting idea than it first sounds. Tilting the device horizontally gives a QWERTY touch keyboard, and holding it vertically gives a calculator-like keypad which provides access to all K verbs and adverbs with a single keypress. Tapping an item from the output history copies it into the edit buffer, and the mobile page adds graphing in the form of the built-in pl for plot line and ps for plot scatter functions, both of which automatically rescale to suit the data provided. The argument to each function specifies the domain. This is the one part of the project that is not a faithful reproduction of anything, and it is arguably where the project is most original, because a K dialect with a full verb set is unusable on a phone keyboard without exactly this kind of layout. What it also means is that the mobile client is a demonstration of how the language maps onto a small input surface, and the documentation on that page is where the detail lives. The browser REPL, the command line REPL and the mobile page together are three different front ends over one interpreter, which is the clearest sign that the implementation sits in one place and the interface is layered on top.

## Conclusion

Adopt oK if you want to learn the K array language and would rather read a small JavaScript implementation than reverse engineer a commercial one, and if you are happy with a project that describes itself as buggy and incomplete. Do not adopt it for anything performance sensitive or for production work, since the project explicitly does not intend to be fast or practical, and use kdb or Kona instead when you need a real K implementation. Before you start, read the oK Manual for the operators and syntax it actually supports, and check which K5 features are still missing rather than assuming parity with the spec.

## FAQ

### What is oK and what language is it written in?

oK is a toy interpreter for a dialect of the K programming language, aimed at implementing K5, and it is written in JavaScript. The project says it is not intended to be fast or practical beyond learning, and that JavaScript was chosen because it is familiar and has first class functions.

### How do I run oK without installing anything?

The easiest way is the browser based REPL, a static page with no backend. It has line commands such as \e to toggle the scratchpad editor, \r to run it, \c to clear the log and \u to generate a code URL, and a ?run= URL parameter runs the remainder of the URL as code.

### How do I run oK from the command line?

With Node.js, using `node test.js` to run the automated test series or `node repl.js` to start the REPL, optionally with a filename argument such as `node repl.js examples/hangman.k` to execute that file. The package manifest maps its only script, start, to node repl.js.

### What are the numbered IO verbs in oK used for?

Dyadic 0: writes the right argument to a destination as text, monadic 0: reads a file or a URL and in the browser performs a synchronous HTTP request returning the status code and response, monadic 1: does the same but expects JSON and parses it into a K data structure, and monadic 5: returns a printable string representation of the right argument.

### Is oK suitable for production use?

No. The project states that oK does not intend to be particularly fast or suitable for any practical purpose beyond learning, and that it should be expected to be buggy, incomplete and occasionally wrong. For real K work the documentation points to the free kdb from Kx Systems and to Kona, an open source reimplementation of K3 and K4.

## Sources

- [Issues](https://github.com/JohnEarnest/ok/issues)
- [JohnEarnest/ok on GitHub](https://github.com/JohnEarnest/ok)
- [License: MIT](https://github.com/JohnEarnest/ok/blob/gh-pages/LICENSE)
- [README](https://github.com/JohnEarnest/ok/blob/gh-pages/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/johnearnest-ok
