# Sprachen und Interop

Elide führt diese Sprachen aus einem einzigen Binary aus:

| Sprache | Status | Läuft als | Starten mit | Interop |
| --- | --- | --- | --- | --- |
| JavaScript | Unterstützt | Skript | `elide app.js`, `elide -s CODE` | Python: `--interop`; WASM: ohne Flag |
| TypeScript | Unterstützt | Skript, Typen entfernt | `elide app.ts`, `elide -l ts -s CODE` | Wie JavaScript |
| Python | Experimentell | Python 3.13 | `elide app.py`, `elide python -m MOD` | JavaScript: `--interop` |
| WebAssembly | Experimentell | WASI-Preview-1-Befehl | `elide app.wasm` (`_start` oder `_main`) | Aus JS/TS, ohne Flag |
| Java, Kotlin | Unterstützt | Kompiliert, läuft auf dem mitgelieferten JDK | `elide run Main.kt`, `elide.pkl`-Projekte | Keine |
| Pkl | Unterstützt | Konfiguration | `elide.pkl`-Manifeste | Keine |

`elide info` listet die Sprachen in Ihrem Binary auf; `elide setup python` fügt Python hinzu. Seiten je Sprache:
[JavaScript & TypeScript](/docs/web), [Python](/docs/python), [Java & Kotlin](/docs/jvm),
[WebAssembly](/docs/wasm).

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

## Python ruft JavaScript auf

```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 importiert 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
```

Der `default`-Export ist das Python-Modul. Verwenden Sie einen `.mjs`-Einstiegspunkt.

## Ohne `--interop`

Jedes Programm führt nur seine Einstiegssprache aus, bei JS/TS zusätzlich WebAssembly. Aufrufe zwischen Sprachen
schlagen fehl:

| Programm | Fehler |
| --- | --- |
| `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.` |

Übergeben Sie `--interop` nur an Programme, die zwischen Sprachen aufrufen. Unter `--interop` schlagen Python-Threads
mit `Creating threads is not allowed.` fehl.

## JavaScript und WebAssembly

```javascript
import { add } from "./math.wasm";
console.log(add(1, 2));
```

`.wasm`-Importe und die `WebAssembly`-API funktionieren in jedem JavaScript- und TypeScript-Programm. Ist Python
installiert, schlagen Module mit SIMD-Instruktionen mit `Vector instructions are not enabled` fehl.

## In der REPL

Die REPL teilt Werte zwischen Sprachen ohne `--interop`; siehe [Interaktive REPL](/docs/repl).

## Beispiele

- [Python ruft JavaScript auf](/docs/code-samples#python-calling-javascript)
- [JavaScript importiert Python](/docs/code-samples#javascript-importing-python)
- [WebAssembly aus JavaScript](/docs/code-samples#webassembly-from-javascript)
