Skip to content

Languages and interop

Which languages Elide runs, how to start each one, and how Python, JavaScript and WebAssembly call each other with --interop and in the REPL.

Read offlineelide help languages

On this page

Elide runs these languages from one binary:

Language Status Runs as Start with Interop
JavaScript Supported Script elide app.js, elide -s CODE Python: --interop; WASM: no flag
TypeScript Supported Script, types stripped elide app.ts, elide -l ts -s CODE As JavaScript
Python Experimental Python 3.13 elide app.py, elide python -m MOD JavaScript: --interop
WebAssembly Experimental WASI Preview 1 command elide app.wasm (_start or _main) From JS/TS, no flag
Java, Kotlin Supported Compiled, run on the bundled JDK elide run Main.kt, elide.pkl projects None
Pkl Supported Configuration elide.pkl manifests None

elide info lists the languages in your binary; elide setup python adds Python. Per-language pages: JavaScript and TypeScript, Python, Java and Kotlin, WebAssembly.

elide --interop — Python calling JavaScript, JavaScript importing Python
 ~/demo  bat mod.py main.mjs
───────┬────────────────────────────────────────────────────────────────────────────────────────────
       │ File: mod.py
       │ Size: 58 B
───────┼────────────────────────────────────────────────────────────────────────────────────────────
   1   │ def greet(name):
   2   │     return f"Hello from Python, {name}!"
───────┴────────────────────────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────────────────────────
       │ File: main.mjs
       │ Size: 58 B
───────┼────────────────────────────────────────────────────────────────────────────────────────────
   1   │ import py from "./mod.py";
   2   │ 
   3   │ console.log(py.greet("Ada"));
───────┴────────────────────────────────────────────────────────────────────────────────────────────
 ~/demo  elide --interop main.mjs
Hello from Python, Ada!
 

Python calling JavaScript

python
# sum.py
from elide import js

print(js("[1,2,3].reduce((a,b)=>a+b,0)"))
utf-8 · python · Lines: 4
Terminal
bash
elide --interop python sum.py
text
6
utf-8 · text · Lines: 1

JavaScript importing Python

python
# mod.py
def greet(name):
    return f"hello {name}"
utf-8 · python · Lines: 3
javascript
// main.mjs
import mod from "./mod.py";
console.log(mod.greet("elide"));
utf-8 · javascript · Lines: 3
Terminal
bash
elide --interop main.mjs
text
hello elide
utf-8 · text · Lines: 1

The default export is the Python module. Use an .mjs entry.

Without --interop

Each program runs only its entry language, plus WebAssembly for JS/TS. Calls between languages fail:

Program Error
sum.py ValueError: polyglot language 'js' not found
main.mjs Cannot import 'mod.py': JavaScript entries run without Python. Re-run with --interop to use it.

Pass --interop only to programs that call between languages. Under --interop, Python threads fail with Creating threads is not allowed.

JavaScript and WebAssembly

javascript
import { add } from "./math.wasm";
console.log(add(1, 2));
utf-8 · javascript · Lines: 2

.wasm imports and the WebAssembly API work in every JavaScript and TypeScript program. When Python is installed, modules that use SIMD instructions fail with Vector instructions are not enabled.

In the REPL

The REPL shares values across languages without --interop; see Interactive REPL.

Samples

Was this page helpful?