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.

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:

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

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?