# Lenguajes e interoperabilidad

Elide ejecuta estos lenguajes desde un único binario:

| Lenguaje | Estado | Se ejecuta como | Iniciar con | Interoperabilidad |
| --- | --- | --- | --- | --- |
| JavaScript | Compatible | Script | `elide app.js`, `elide -s CODE` | Python: `--interop`; WASM: sin opción |
| TypeScript | Compatible | Script, sin tipos | `elide app.ts`, `elide -l ts -s CODE` | Como JavaScript |
| Python | Experimental | Python 3.13 | `elide app.py`, `elide python -m MOD` | JavaScript: `--interop` |
| WebAssembly | Experimental | Comando WASI Preview 1 | `elide app.wasm` (`_start` o `_main`) | Desde JS/TS, sin opción |
| Java, Kotlin | Compatible | Compilado, se ejecuta en el JDK incluido | `elide run Main.kt`, proyectos `elide.pkl` | Ninguna |
| Pkl | Compatible | Configuración | Manifiestos `elide.pkl` | Ninguna |

`elide info` lista los lenguajes de su binario; `elide setup python` añade Python. Páginas por lenguaje:
[JavaScript y TypeScript](/docs/web), [Python](/docs/python), [Java y Kotlin](/docs/jvm),
[WebAssembly](/docs/wasm).

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

## Python llama a 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 importa 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
```

La exportación `default` es el módulo de Python. Use una entrada `.mjs`.

## Sin `--interop`

Cada programa ejecuta solo su lenguaje de entrada, más WebAssembly en JS/TS. Las llamadas entre lenguajes fallan:

| Programa | 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.` |

Pase `--interop` solo a los programas que hacen llamadas entre lenguajes. Con `--interop`, los hilos de Python fallan
con `Creating threads is not allowed.`

## JavaScript y WebAssembly

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

Las importaciones de `.wasm` y la API `WebAssembly` funcionan en todos los programas de JavaScript y TypeScript. Cuando
Python está instalado, los módulos que usan instrucciones SIMD fallan con `Vector instructions are not enabled`.

## En el REPL

El REPL comparte valores entre lenguajes sin `--interop`; consulte [REPL interactivo](/docs/repl).

## Ejemplos

- [Python que llama a JavaScript](/docs/code-samples#python-calling-javascript)
- [JavaScript que importa Python](/docs/code-samples#javascript-importing-python)
- [WebAssembly desde JavaScript](/docs/code-samples#webassembly-from-javascript)
