Klong (K) on Miren
Klong is an open-source array language in the K/APL family.
Array languages don't ship HTTP servers, so — as with COBOL and
Bash — this guide has the Klong program print an HTTP response and puts
socat in front of it to own the socket. It uses KlongPy, a
pip-installable Klong implementation.
Ask your AI coding agent to "set up this Klong app on Miren" after installing the
Miren agent skills. It adds the Dockerfile.miren and the socket
front-end, and deploys — using this page as its reference.
Do you need a Dockerfile?
Yes. Add a Dockerfile.miren to your project root. Miren builds from it instead of
guessing the stack — see Using Dockerfile.miren.
Miren auto-detects and builds common stacks (Python, Node, Bun, Go, Ruby, Rust) without a Dockerfile. This language isn't one of them yet — if you'd like first-class support, request it.
The program
.d writes a string to standard output verbatim. Put a complete HTTP response —
status line, headers, a blank line, then the body — in hello.kg:
.d("HTTP/1.1 200 OK
Content-Type: text/plain
Connection: close
Hello from Klong on Miren!
")
Run the program as a file (kgpy hello.kg), not with -e or over a pipe — those
start the REPL and echo the expression result ("…" with quotes) alongside your
output. In file mode only your .d bytes are written.
The socket front-end
The program doesn't bind a port — socat does. Miren injects PORT, and socat's
TCP-LISTEN binds all interfaces; fork runs Klong once per connection:
web: socat TCP-LISTEN:$PORT,reuseaddr,fork EXEC:'kgpy /app/hello.kg'
Miren's HTTP ingress terminates TLS and handles the public HTTP layer in front of your
app, so socat only needs to hand each accepted connection to your program — it isn't
exposed to raw internet traffic. The one practical limit is that fork spawns a process
per request, so this suits low-traffic endpoints and tooling rather than high-throughput
services.
The Dockerfile
Create Dockerfile.miren in your project root. KlongPy installs from PyPI (it also needs
colorama for its CLI), and socat comes from apt:
FROM python:3.12-slim
RUN pip install --no-cache-dir klongpy colorama \
&& apt-get update -y && apt-get install -y socat && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY hello.kg /app/
EXPOSE 8080
.dockerignore
.git
Deploy
Create .miren/app.toml naming your app and deploy from your project root:
name = "klong-bench"
miren deploy
Even with a Dockerfile.miren, Miren needs at least one service defined — the web:
line above. Without it the deploy stops with no services defined.
Agent quick reference
- Detection: none — requires
Dockerfile.miren - Runtime: KlongPy (
pip install klongpy colorama) onpython:3.12-slim - Serving: the Klong program
.d-prints a full HTTP response;socatowns the socket - Run from a file:
kgpy hello.kg(file mode) —-e/pipe modes echo the result too - Service is required:
Procfileweb: socat TCP-LISTEN:$PORT,reuseaddr,fork EXEC:'kgpy /app/hello.kg' - Port:
socat TCP-LISTEN:$PORTbinds0.0.0.0
Next steps
- COBOL on Miren and Bash on Miren — the same
socatpattern - Using Dockerfile.miren — how custom builds work
- Deployment — how deploys build and activate