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.

On this page

Elide runs these languages from one binary:

LanguageStatusRuns asStart withInterop
JavaScriptSupportedScriptelide app.js, elide -s CODEPython: --interop; WASM: no flag
TypeScriptSupportedScript, types strippedelide app.ts, elide -l ts -s CODEAs JavaScript
PythonExperimentalPython 3.13elide app.py, elide python -m MODJavaScript: --interop
WebAssemblyExperimentalWASI Preview 1 commandelide app.wasm (_start or _main)From JS/TS, no flag
Java, KotlinSupportedCompiled, run on the bundled JDKelide run Main.kt, elide.pkl projectsNone
PklSupportedConfigurationelide.pkl manifestsNone

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

0:22 / 0:22

Python calling JavaScript

# sum.py
from elide import js

print(js("[1,2,3].reduce((a,b)=>a+b,0)"))
elide --interop python sum.py
6

JavaScript importing Python

# mod.py
def greet(name):
    return f"hello {name}"
// main.mjs
import mod from "./mod.py";
console.log(mod.greet("elide"));
elide --interop main.mjs
hello elide

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:

ProgramError
sum.pyValueError: polyglot language 'js' not found
main.mjsCannot 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

import { add } from "./math.wasm";
console.log(add(1, 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?