# 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.

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](https://elide.help/docs/web), [Python](https://elide.help/docs/python), [Java and Kotlin](https://elide.help/docs/jvm),
[WebAssembly](https://elide.help/docs/wasm).

<img src="https://elide.help/assets/demos/interop.gif" alt="elide --interop — Python calling JavaScript, JavaScript importing Python" width="1591" height="728" loading="lazy" decoding="async" class="rounded-lg border border-border my-6 w-full" />

## Python calling JavaScript

```python
# sum.py
from elide import js

print(js("[1,2,3].reduce((a,b)=>a+b,0)"))
```

```bash
elide --interop python sum.py
```

```text
6
```

## JavaScript importing Python

```python
# mod.py
def greet(name):
    return f"hello {name}"
```

```javascript
// main.mjs
import mod from "./mod.py";
console.log(mod.greet("elide"));
```

```bash
elide --interop main.mjs
```

```text
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:

| 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));
```

`.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](https://elide.help/docs/repl).

## Samples

- [Python calling JavaScript](https://elide.help/docs/code-samples#python-calling-javascript)
- [JavaScript importing Python](https://elide.help/docs/code-samples#javascript-importing-python)
- [WebAssembly from JavaScript](https://elide.help/docs/code-samples#webassembly-from-javascript)
