Implementation of Kap, an array-based programming language inspired by APL. https://kapdemo.dhsdevelopments.com/
  • Kotlin 98.9%
  • Emacs Lisp 0.6%
  • CSS 0.3%
  • JavaScript 0.1%
Find a file
Elias Mårtenson a484c5b2b2
All checks were successful
ci/woodpecker/push/make Pipeline was successful
Upgrade Kotlin to 2.4.0-Beta1
2026-03-31 22:39:42 +08:00
.idea Some experiments with calcite 2026-01-21 00:25:40 +08:00
.run Implementation of mapAppend 2024-12-23 16:27:57 +08:00
.woodpecker Added libatomic1 to build dependencies 2025-11-08 14:54:58 +08:00
array Implementation of object viewer 2026-03-30 23:49:02 +08:00
client-java Some cleanup 2026-03-08 22:25:28 +08:00
clientweb2 Basic markup support in repl 2026-03-27 21:42:30 +08:00
common-gui Improvements to gui2 2026-03-12 19:59:58 +08:00
contrib Basic markup support in repl 2026-03-27 21:42:30 +08:00
demo Updated the map api 2025-12-22 21:49:59 +08:00
docs Implementation of object viewer 2026-03-30 23:49:02 +08:00
experimental Basic markup support in repl 2026-03-27 21:42:30 +08:00
forms/forms-common Some cleanup 2026-03-08 22:25:28 +08:00
fxgraph Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
gradle/wrapper Upgrade gradle to 9.3.1 2026-03-22 00:15:01 +08:00
gui Basic markup support in repl 2026-03-27 21:42:30 +08:00
gui2 Small improvements to ui 2026-03-31 22:34:55 +08:00
jline-kap Error highlighting 2026-03-20 00:20:03 +08:00
kap-util Fixed incorrect documentation 2026-03-25 00:49:14 +08:00
kotlin-js-store Upgrade Kotlin to 2.3.20-Beta2 2026-03-10 23:07:36 +08:00
mpbignum Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
mpmaths Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
perf-test Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
perf-test-jvm Some cleanup 2026-03-08 22:25:28 +08:00
scripts The clientweb2 project should use multiple child projects 2025-11-08 22:22:29 +08:00
standalonejs Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
test-tools Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
text-client Fixes after running source code analysis 2026-03-26 01:33:18 +08:00
.gitignore Refactored some maths functions 2025-05-01 22:21:08 +08:00
build.gradle Upgrade Kotlin to 2.4.0-Beta1 2026-03-31 22:39:42 +08:00
COPYING Removed namespace 'graph' 2024-10-09 21:46:42 +08:00
gradle.properties Implement rowspan and colspan in forms 2025-11-13 23:21:58 +08:00
gradlew Upgrade gradle to 9.3.1 2026-03-22 00:15:01 +08:00
gradlew.bat Update gradle wrapper to match gradle version 2025-11-10 23:16:57 +08:00
README.md Update readme and build scripts to use Java 25 2025-11-08 14:50:33 +08:00
settings.gradle Created a module for common gui code 2026-02-22 16:25:52 +08:00

Kap

An implementation of an APL-like language in Kotlin. The implementation is a Kotlin Multiplatform project, and can be compiled to Java, natively and to Javascript.

Summary

Kap is an array-based language that is inspired by APL. The language provides a powerful set of tools that allows the programmer to work with arrays of data instead of element by element. This allows the code to be incredibly compact, and often reduces what would otherwise be tens or even hundreds of lines of code into single line.

Features that sets Kap apart from APL include:

  • Local variable scopes including closures
  • First class functions
  • Custom syntax extensions (this allows features like if and while to be implemented as part of the standard library rather than being part of the language syntax)
  • Lazy evaluation
  • Parallel evaluation
  • Structural under (inspired by BQN)
  • Bigint and rational arithmetic
  • Simple sound and graphic API
  • Line/bar/pie charts

The main website for the project is: https://kapdemo.dhsdevelopments.com/

What the language looks like

As a language based on APL, it uses non-ASCII symbols with most fundamental functions being a single character. This may make the language seem complicated, but it's actually rather simple once one learns the general syntax.

The first line of code in the following example assigns a string to the variable A, and the second line splits the string at instances of -, returning an array of arrays (a string in Kap is nothing more than a one-dimensional array of characters):

A ← "this-is-a-demo"
A ⊂⍨ A≠@-

Typing the above code into the REPL will display the following result:

┌→─────────────────────┐
│"this" "is" "a" "demo"│
└──────────────────────┘

The box around the result indicates that the result is an array. In this case it is a one-dimensional array with 4 elements, each of which is an array of characters (i.e. string).

More examples can be found on the Kap examples web page.

Build dependencies

The Java version of Kap has been tested on Linux, Macos and Windows. The only dependency is Java 25.

Running the JavaFX based UI

The most feature-complete way to run Kap is to use the JVM client. It provides a nicer user interface, an editor, highlighting of the location of errors, ability to draw graphics, and many other features.

To start the client, simply run:

./gradlew gui:run

Running the Linux native version

To build the native Linux version, several dependencies needs to be installed. The development packages for the following libraries needs to be available:

  • Libedit
  • Libcurl
  • ICU
  • Jansson
  • GMP
  • Ncurses
  • Alsa
  • Libffi
  • OpenSSL

Fedora Linux packages

On Fedora, the necessary packages can be installed using:

dnf install java-25-openjdk-devel jansson-devel libicu-devel libffi-devel alsa-lib-devel ncurses-devel libedit-devel gmp-devel libicu-devel libxcrypt-compat libcurl-devel openssl-devel sdl2-compat-devel

Ubuntu packages

On Ubuntu, use the following command to install the dependencies:

apt-get install openjdk-25-jdk libicu-dev libcurl4-openssl-dev libjansson-dev libgmp-dev libedit-dev libasound2-dev libffi-dev libssl-dev libsdl2-dev

Building the Linux version

To build the native Linux binary, run the following command:

./gradlew text-client:linuxMainBinaries

When running the Linux binary, the path to the standard library needs to be passed to the executable:

text-client/build/bin/linux/releaseExecutable/text-client.kexe --lib-path=array/standard-lib

There is currently no support for native compilation on Windows or OSX. As long as the dependencies are available, it should be possible to make it work. Help appreciated if anyone is interested in working on it.

Web client

The application also compiles to Javascript, and it's possible to run it in a browser. Note that some functionality is missing from the Javascript version. For example, network and file operations are currently not implemented.

You can try the web UI here: https://kapdemo.dhsdevelopments.com/clientweb2/

Documentation

Work on the documentation is in progress, but it's still limited.

There is a tutorial which is incomplete: https://kapdemo.dhsdevelopments.com/tutorial.html

The following document explains the differences between Kap and APL, which is useful for readers who already are familiar with APL: https://kapdemo.dhsdevelopments.com/kap-comparison.html

The reference documentation can be found here: https://kapdemo.dhsdevelopments.com/reference.html

Anyone interested in learning more can ask questions on the Matrix channel.

Contributions

The main repository for this project is available from Codeberg: https://codeberg.org/loke/array

For discussions about this project, feel free to join the Matrix channel: #kap:dhsdevelopments.com.