Skip to content
A source-to-source transpiler to convert Clojure to multiple target languages (Rust, C++, Java, ...)
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/a [cli] Adds a command line interface for compiling Mar 26, 2020

Kalai Transpiler

Kalai transpiler is a source-to-source transpiler to convert Clojure to multiple target languages (Rust, C++, Java, ...).

The goal of Kalai is to allow useful algorithms to be encoded once and then automatically be made available natively to other target programming languages.


See why Clojure is good for writing transpilers.


Supported forms

The forms that are currently supported are listed in interface.clj.


If you have code written in your.namespace, then you can emit code as follows, assuming there is a file your/namespace.clj relative to where the program is run:

lein run -i your -o someoutdir -l rust

In this example, an output file will be written to someoutdir/your/

Example demo 1 has input code at test/kalai/demo/demo01.clj and emitter tests at test/kalai/demo/demo01.clj.

Example demo 2 has input code at test/kalai/demo/demo02.clj and emitter tests at test/kalai/demo/demo02.clj and logic tests at test/kalai/demo/demo02_logic_test.clj.

Implemented target languages

  • Rust
  • C++
  • Java
  • Clojure (Kalai is source compatible with Clojure)

See also kalai.emit.langs/TARGET-LANGS


Extending or adding languages

Clojure supports namespaced keywords to enable the dynamic dispatch fallback hierarchies for multimethods. The namespaced keywords for the target languages follow the Clojure derivation tree:

  • ::l/curlybrace ("curly brace" languages)
    • ::l/rust (Rust)
    • ::l/cpp (C++)
    • ::l/java (Java)

To extend or add implementations, add multimethod definitions in kalai.emit.impl/mylang.clj.


Issues and Pull requests welcome!


Copyright © 2020 The Kalai Authors.

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: Unicode License (

You can’t perform that action at this time.