# Elide documentation > Elide is a high-performance runtime and toolchain for Kotlin, Java, JavaScript, TypeScript and Python. This file contains every page of https://elide.help in navigation order. Each page starts with its title and URL; the index is https://elide.help/llms.txt. # Elide Overview URL: https://elide.help/ > A memory-safe, high-performance runtime that runs JavaScript, TypeScript, Python, Java, Kotlin and WebAssembly and builds and tests projects. Start here. Backend services on managed runtimes are limited by memory, and DRAM prices have more than tripled since 2024. Elide is designed around that: a memory-safe, high-performance runtime shipped as one binary that runs JavaScript, TypeScript, Python, Java, Kotlin, and WebAssembly, and builds, tests, formats, and installs dependencies for your projects. ## Start here 1. [Install Elide](https://elide.help/docs/installation). 2. [Run your first program](https://elide.help/docs/getting-started). 3. Pick a language: [JavaScript and TypeScript](https://elide.help/docs/web), [Python](https://elide.help/docs/python), [Java and Kotlin](https://elide.help/docs/jvm), or [WebAssembly](https://elide.help/docs/wasm). With `--interop`, languages share one process and pass values between them: One REPL session — JavaScript values used from Python ## Common commands ```bash elide run app.ts # run a file elide python script.py # run Python with CPython-style arguments elide repl # interactive REPL elide init # start a new project from a template elide adopt # migrate an existing project with an AI coding agent elide install # install Maven dependencies elide install --ecosystems=npm # install npm dependencies elide build # build the project elide test # run tests elide format -- src # format Java and Kotlin sources elide serve --no-tui ./dist # serve a directory over HTTP elide --help-all # every command and flag elide help # any page of these docs, in the terminal ``` ## Explore further - [Code Samples](https://elide.help/docs/code-samples) - [Project setup](https://elide.help/docs/projects) - [Adopt an Existing Project](https://elide.help/docs/toolchain/usage/adopt) - [Languages and Interop](https://elide.help/docs/languages) - [CLI Reference](https://elide.help/docs/cli-references) - [Compatibility Matrix](https://elide.help/docs/compatibility) - [API Overview](https://elide.help/docs/api-overview) - [Agentic engineering](https://elide.help/docs/agentic-engineering) - Coming from another runtime: [Node](https://elide.help/docs/elide-for-node), [Bun](https://elide.help/docs/elide-for-bun), [Deno](https://elide.help/docs/elide-for-deno), [Python](https://elide.help/docs/elide-for-python), [Java](https://elide.help/docs/elide-for-java), [Kotlin](https://elide.help/docs/elide-for-kotlin) --- # Installation URL: https://elide.help/docs/installation > Install Elide on macOS, Linux, WSL or Windows with the install script, PowerShell, npm or a package manager, pick a release channel, and add Python. Elide has two channels: `release` (versions such as `1.6.0`) and `nightly` (daily builds). The install scripts default to `release`. ## macOS, Linux, or WSL ```bash curl -sSL --tlsv1.2 elide.sh | bash ``` Installs under `${ELIDE_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/elide}` and adds `bin` to your shell profile. Pass options after `bash -s --`: ```bash curl -sSL --tlsv1.2 elide.sh | bash -s -- --channel=nightly --with-python ``` | Option | Effect | | --- | --- | | `--channel=release` or `--channel=nightly` | Select the channel (default `release`). | | `--install-rev=VERSION` | Install a specific version. | | `--install-dir=PATH` | Install somewhere else. | | `--with-python` | Also install the Python component. | | `--no-path` | Leave shell profiles unchanged. | | `--help` | List every option without installing. | ## Windows ```powershell & ([scriptblock]::Create((irm https://elide.sh/install.ps1))) ``` Installs under `$env:ELIDE_HOME`, or `$env:LOCALAPPDATA\elide` when that is unset. Options: `-Channel`, `-InstallRev`, `-InstallDir`, `-WithPython`, and `-NoPath`. ## npm ```bash npm install -g @elide-dev/elide ``` `latest` tracks `release`; install `@elide-dev/elide@nightly` for nightly. Set `ELIDE_WITH_PYTHON=1` to include Python. ## Python Python is an optional component: ```bash elide setup python ``` | Install method | Python | | --- | --- | | Install script | `--with-python` (`-WithPython` on Windows), or `elide setup python` later | | npm | `ELIDE_WITH_PYTHON=1` during `npm install` | | Homebrew | Included | | Container images | Included | | apt, RPM, MSI, macOS installers | Not available; use one of the methods above | `elide setup python` uses the binary's own channel; `--channel=release` or `--channel=nightly` overrides it. ## Other methods - [Packages & Installers](https://elide.help/docs/installation/packages): Homebrew, apt, RPM, macOS and Windows installers - [Container Images](https://elide.help/docs/installation/containers) - [Continuous Integration](https://elide.help/docs/installation/ci-cd) - [GitHub Releases](https://github.com/elide-dev/elide/releases): archives, checksums, and older builds. Keep an archive's `bin/` and `lib/` together; `bin/elide` needs `lib/`. Update a script install with `elide upgrade`, and a package-manager install through its manager. ## Verify the install ```bash elide --version elide info ``` Verifying an Elide installation from the command line `elide info` lists the available languages, including `python` when it is installed. If the shell cannot find `elide`, open a new terminal or add the install's `bin` folder to `PATH`. ## System requirements | Platform | Architecture | Minimum | Python component | | --- | --- | --- | --- | | Linux | `amd64` | glibc 2.34, kernel 4.18 | Yes | | Linux | `arm64` | glibc 2.34, kernel 4.18 | Yes | | macOS | Apple Silicon (`arm64`) | macOS 11 | Yes | | Windows | `amd64` | — | Yes | - Ubuntu 22.04, Debian 12, RHEL 9, Fedora 35 and later meet the glibc floor. On older distributions (for example Debian 11) `elide` exits with `version GLIBC_2.34 not found`; use a [container image](https://elide.help/docs/installation/containers) there. - Alpine and other musl-based distributions are not supported (`exec elide: no such file or directory`). - Intel Macs are not supported. Check your glibc with: ```bash ldd --version | head -1 ``` --- # Packages and installers URL: https://elide.help/docs/installation/packages > Install Elide with Homebrew, apt, RPM, or the macOS and Windows installers, upgrade through the package manager, and verify checksums and signatures. Upgrade these installs through their package manager, not `elide upgrade`. Only Homebrew includes Python; see [Installation](https://elide.help/docs/installation#python). ## Homebrew ```bash brew install elide-dev/elide/elide brew upgrade elide ``` The [`elide-dev/homebrew-elide`](https://github.com/elide-dev/homebrew-elide) tap tracks `nightly` on macOS (Apple Silicon) and Linux (`amd64`, `arm64`). ## Debian and Ubuntu (apt) ```bash curl -fsSL https://keys.elide.dev/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/elide.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/elide.gpg]" \ "https://dl.elide.dev release main" | sudo tee /etc/apt/sources.list.d/elide.list sudo apt update && sudo apt install elide ``` Replace `release` with `nightly` for daily builds. Upgrade with `sudo apt update && sudo apt upgrade elide`. The package installs into `/opt/elide/`, with `/opt/elide/current` and `/usr/bin/elide` pointing at it. ## Fedora and RHEL (RPM) ```bash sudo dnf install ./elide__.rpm ``` Download the RPM for `amd64` or `arm64` from [GitHub Releases](https://github.com/elide-dev/elide/releases); there is no yum repository. Upgrade by installing a newer RPM. ## Native installers These links point at the latest `release`; replace `release` with `nightly` in a URL for the latest nightly. | Platform | Format | Download | Checksum | | --- | --- | --- | --- | | macOS `arm64` | PKG | [elide-installer.macos-arm64.pkg](https://elide.zip/artifacts/release/latest/elide-installer.macos-arm64.pkg) | [sha256](https://elide.zip/artifacts/release/latest/elide-installer.macos-arm64.pkg.sha256) | | macOS `arm64` | DMG | [elide-installer.macos-arm64.dmg](https://elide.zip/artifacts/release/latest/elide-installer.macos-arm64.dmg) | [sha256](https://elide.zip/artifacts/release/latest/elide-installer.macos-arm64.dmg.sha256) | | Windows `amd64` | MSI | [elide-installer.windows-amd64.msi](https://elide.zip/artifacts/release/latest/elide-installer.windows-amd64.msi) | [sha256](https://elide.zip/artifacts/release/latest/elide-installer.windows-amd64.msi.sha256) | ## Verify a download Each installer has a SHA-256 checksum (`.sha256`) and a GPG signature (`.asc`). GitHub Releases also carries a Sigstore bundle (`.bundle`). With the download and its `.sha256` file in one directory: ```bash sha256sum -c .sha256 # Linux shasum -a 256 -c .sha256 # macOS ``` PowerShell: ```powershell $file = "elide-installer.windows-amd64.msi" Invoke-WebRequest -Uri "https://elide.zip/artifacts/release/latest/$file" -OutFile $file Invoke-WebRequest -Uri "https://elide.zip/artifacts/release/latest/$file.sha256" -OutFile "$file.sha256" $expected = (Get-Content "$file.sha256").Split(" ")[0] $actual = (Get-FileHash $file -Algorithm SHA256).Hash.ToLower() if ($expected -eq $actual) { Write-Host "OK" } else { Write-Host "MISMATCH" } ``` Signature: ```bash curl -fsSL https://keys.elide.dev/gpg.key | gpg --import curl -LO https://elide.zip/artifacts/release/latest/elide-installer.windows-amd64.msi.asc gpg --verify elide-installer.windows-amd64.msi.asc elide-installer.windows-amd64.msi ``` A valid signature reports `Good signature from "Elide Releases (Release key, Elide 1.0 and up) "`. GPG warns that the key is not certified until you sign it yourself. --- # Container images URL: https://elide.help/docs/installation/containers > Run Elide with Docker or any OCI runtime from the elide and bash container images for amd64 and arm64, with Python included, using version or dated nightly tags. Linux images for Docker and other OCI runtimes, on `amd64` and `arm64`, with Python included. | Image | Entrypoint | Use | | --- | --- | --- | | `elide.dev/elide` | `elide` | Run a command directly. | | `elide.dev/bash` | `bash` | Open a shell with Elide on `PATH`. | Both are also published as `ghcr.io/elide-dev/elide` and `ghcr.io/elide-dev/bash`. ## Tags | Tag | Points at | | --- | --- | | `1.6.0` | That release. | | `1.6`, `1` | The newest release in that line. | | `latest` | The newest release. | | `nightly` | The newest nightly build. | | `nightly-` | The nightly build from that date. | Pin a version or dated nightly tag for reproducible builds. The [`elide`](https://github.com/elide-dev/elide/pkgs/container/elide) and [`bash`](https://github.com/elide-dev/elide/pkgs/container/bash) package pages list every tag. ## Run a command ```bash docker run --rm elide.dev/elide:1.6.0 --version docker run --rm -v "$PWD":/work -w /work elide.dev/elide:1.6.0 run app.js # run in the current directory ``` ## Open a shell ```bash docker run --rm -it elide.dev/bash:1.6.0 ``` --- # Continuous integration URL: https://elide.help/docs/installation/ci-cd > Install Elide in GitHub Actions with the setup-elide action, pin a release instead of the default nightly channel, and see an example workflow. The [setup-elide](https://github.com/elide-dev/setup-elide) action installs Elide and adds it to `PATH`. It defaults to `nightly`; pin a release: ```yaml - name: Set up Elide uses: elide-dev/setup-elide@v4.2.0 with: version: 1.6.0 channel: release ``` The action's README lists its other inputs and outputs. ## Example workflow ```yaml name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: elide-dev/setup-elide@v4.2.0 with: version: 1.6.0 channel: release - run: elide install --workspace - run: elide format --list-files -- --dry-run src - run: elide test ``` `elide install --workspace` installs every ecosystem the project declares; plain `elide install` installs Maven only. The format step fails when a file under `src` needs formatting. The action does not install Python; add a step for it: ```yaml - run: elide setup python ``` To trace `elide build` and `elide test` in CI, see [Builds and tests in CI](https://elide.help/docs/opentelemetry/runtime#builds-and-tests-in-ci). --- # Getting started URL: https://elide.help/docs/getting-started > Install Elide, create a project with `elide init`, run TypeScript, Python and Kotlin files, add Maven and npm dependencies, then test and build. Install Elide, create a project, then run, test and build it. ## Install macOS, Linux or WSL: ```bash curl -sSL --tlsv1.2 elide.sh | bash ``` Windows (PowerShell): ```powershell & ([scriptblock]::Create((irm https://elide.sh/install.ps1))) ``` npm, on any platform: ```bash npm install -g @elide-dev/elide ``` Open a new terminal and check the install: ```bash elide --version ``` Homebrew, containers, release channels and the Python component: [Installation](https://elide.help/docs/installation). ## Create a project ```bash mkdir hello && cd hello elide init --plain --skip-defaults --template ktjvm ``` | File | Contents | | --- | --- | | `elide.pkl` | The project manifest: its name and the JVM entrypoint. | | `src/main/com/example/Hello.kt` | A `main` function that prints `Hello Elide!`. | | `src/test/com/example/HelloTest.kt` | A `kotlin.test` test for the greeting. | ```pkl amends "elide:project.pkl" name = "Sample Project" jvm { main = "com.example.HelloKt" } ``` `elide init --templates` lists the other templates: `java`, `web-simple`, `web-demo` and `workspace`. Without flags, `elide init` opens an editor for the template's parameters. For an existing Java or Kotlin project, run `elide adopt` in it ([Adopt an Existing Project](https://elide.help/docs/toolchain/usage/adopt)). ## Run a file Source files run directly, in a project or not. TypeScript needs no compile step: ```ts // hello.ts const name: string = "TypeScript"; console.log(`Hello from ${name}!`); ``` ```bash elide run hello.ts ``` ```terminaloutput Hello from TypeScript! ``` Running a TypeScript file directly with Elide Python needs the Python component (`elide setup python`): ```python # hello.py print("Hello from Python!") ``` ```bash elide python hello.py ``` ```terminaloutput Hello from Python! ``` Kotlin and Java files run the same way: ```kotlin // hello.kt fun main() { println("Hello from Kotlin!") } ``` ```bash elide run hello.kt ``` ```terminaloutput Hello from Kotlin! ``` In the project, `elide run` with no file builds and runs `jvm.main`, which prints `Hello Elide!`. ### Executable scripts Start a file with `#!/usr/bin/env elide` and mark it executable. Arguments reach `process.argv` or `sys.argv`: ```ts #!/usr/bin/env elide const n: number = 42; console.log(`ts ${n}`, process.argv.slice(2).join(" ")); ``` ```bash chmod +x hello.ts ./hello.ts --flag x ``` ```terminaloutput ts 42 --flag x ``` The same line works for `.js`, `.mjs` and `.py` files. A file without an extension runs as JavaScript. ## Add a dependency Declare packages in `elide.pkl`: ```pkl dependencies { maven { packages { "com.google.guava:guava:33.4.8-jre" } } npm { packages { "zod@3.25.76" } } } ``` ```bash elide install # Maven elide install --ecosystems=maven,npm # Maven and npm ``` npm packages install into `node_modules`, and npm also reads `package.json`. `elide install` does not install `pypi` packages. See [Dependencies](https://elide.help/docs/toolchain/dependencies). ## Test ```bash elide test ``` ```terminaloutput com.example.HelloTest ✓ testGreeting() [15ms] 1 pass 0 skip 0 fail Ran one test across one file. (0.67s) ``` `elide test` also runs JavaScript and TypeScript `node:test` files; see [Testing](https://elide.help/docs/toolchain/testing). ## Build ```bash elide build ``` Outputs and build state go in `.dev/`. `elide build --inspect` lists the tasks and their options; see [Build Tasks](https://elide.help/docs/toolchain/build-tasks). ## Next steps - Languages: [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). - [Toolchain](https://elide.help/docs/toolchain): building, testing, formatting and packaging. - [Project setup](https://elide.help/docs/projects): scripts, workspaces and pinning the Elide version. - [Development Server](https://elide.help/docs/dev-server): `elide dev` serves a directory or server script with page reload. - [Code Samples](https://elide.help/docs/code-samples): one-file examples with their expected output. --- # JavaScript and TypeScript with Elide URL: https://elide.help/docs/web > Run JavaScript and TypeScript with Elide without a compile step or tsconfig.json: CommonJS and ES modules, npm packages, node:test tests and servers. Elide runs JavaScript and TypeScript directly, with CommonJS, ES modules, and a subset of the Node and Web APIs. > [!TIP] TypeScript runs as written > No compile step and no `tsconfig.json`: `elide app.ts` runs the file. ```bash elide run app.js elide run app.ts elide app.ts elide run -s 'console.log(1 + 1)' ``` Extensions: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`. JSX and TSX are transformed; install the runtime they import, such as `react/jsx-runtime`. Elide provides no UI framework or DOM. ## npm packages Declare dependencies in `package.json`. Plain `elide install` skips npm, so pass `--ecosystems=npm`: ```json { "type": "module", "dependencies": { "zod": "3.24.1" } } ``` ```ts // app.ts import { z } from "zod"; const User = z.object({ name: z.string() }); console.log(`Hello, ${User.parse({ name: "Ada" }).name}!`); ``` ```bash elide install --ecosystems=npm elide run app.ts ``` elide install — package.json dependencies used from TypeScript Packages go into `node_modules`. If the project also has Maven dependencies, use `--ecosystems=maven,npm` or `--workspace`. Lockfiles and options: [NPM Installer](https://elide.help/docs/toolchain/web/npm). ## Tests `elide test` finds `*.test.ts`, `*.spec.js`, files under `test/`, and similar. Write tests with `node:test`: ```ts // math.test.ts import test from "node:test"; import assert from "node:assert"; test("adds", () => { assert.equal(1 + 1, 2); }); ``` ```bash elide test ``` ## Servers ```bash elide serve --no-tui ./dist # static files on 127.0.0.1:8080 elide dev --no-tui ./src # port 3000; pages reload on change ``` Given a script, `serve` and `dev` run it; a module that exports a `fetch` handler is served directly. See [Development Server](https://elide.help/docs/dev-server). ## Samples - [TypeScript without a build](https://elide.help/docs/code-samples#typescript-without-a-build) - [HTTP handler](https://elide.help/docs/code-samples#http-handler) - [TypeScript tests](https://elide.help/docs/code-samples#typescript-tests) - [Local server and fetch](https://elide.help/docs/code-samples#local-server-and-fetch) ## More Implemented Node and Web modules: [API Overview](https://elide.help/docs/api-overview). SQLite, PostgreSQL and MySQL drivers: [Databases](https://elide.help/docs/api-database). Measured results: [Compatibility Matrix](https://elide.help/docs/compatibility). Traces, metrics, and logs through `@opentelemetry/api`, with no SDK: [OpenTelemetry in JavaScript](https://elide.help/docs/opentelemetry/javascript). --- # Python with Elide URL: https://elide.help/docs/python > Run Python 3.13 with Elide and CPython's arguments: install the Python component, the bundled standard library, JavaScript interop and known limitations. Python support is experimental in 1.6.0. > [!TIP] No CPython install > Elide runs Python 3.13 and its standard library itself. Add the optional Python component: ```bash elide setup python ``` `--channel=release` or `--channel=nightly` picks the channel; `--force` reinstalls. apt and RPM installs cannot add it; see [Installation](https://elide.help/docs/installation#python). Without the component, Python commands print `Python support is not installed. Run 'elide setup python' to add it.` and exit `2`. ## Run Python `elide python` takes the same arguments as `python`: ```bash elide python app.py --name Elide --count 2 # sys.argv: ['app.py', '--name', 'Elide', '--count', '2'] elide python -c 'import sys; print(sys.version)' elide python -m json.tool input.json echo 'print("from stdin")' | elide python - ``` Tokens after the script, `-c CMD`, or `-m MODULE` go to the program. Bare `elide python` starts the REPL in a terminal and reads standard input otherwise. Running a Python program with command-line arguments in Elide The general commands run `.py` files with the same `sys.argv`: ```bash elide app.py elide run app.py elide -l python -s 'print(1 + 1)' ``` ### Interpreter options Put these before the script, `-c`, or `-m`. `elide --help-all` lists them under "Python interpreter options". | Flag | Effect | | --- | --- | | `-c CMD` | Run `CMD` as the program; trailing tokens become `sys.argv[1:]`. | | `-m MODULE` | Run a library module as `__main__`. | | `-s` | Don't add the user site directory to `sys.path`. | | `-I` | Isolated mode. | | `-E` | Ignore `PYTHON*` environment variables. | | `-S` | Don't `import site` on startup. | | `-P` | Don't prepend a potentially unsafe path to `sys.path`. | | `-B` | Don't write bytecode files. | | `-u` | Unbuffered standard output and error. | | `-O` | Optimization level; repeat for `-OO`. | | `-b` | Warn on `bytes`/`str` comparisons; repeat to raise errors. | | `-W ARG` | Warning control; repeatable. | | `-x` | Accepted for compatibility; no effect. | Two flags are on by default: `-S`, because Elide builds `sys.path` itself and skips `site` for startup time, and `-B`. `sys.flags` reports both. To import `site` (`.pth` files, `sitecustomize`), pass `-X polyglot.python.NoSiteFlag=false`; to write bytecode, pass `-X polyglot.python.DontWriteBytecodeFlag=false`. ## Standard library The standard library includes `json`, `pathlib`, `sqlite3`, `ssl`, `zlib`, and `ctypes`. `bz2` and `lzma` need no system `libbz2` or `liblzma`. For the database drivers Elide includes, see [Databases](https://elide.help/docs/api-database). ## JavaScript interop With `--interop`, Python evaluates JavaScript through the built-in `elide` module: ```python # sum.py from elide import js print(js("[1, 2, 3].reduce((a, b) => a + b, 0)")) ``` ```bash elide --interop python sum.py ``` JavaScript and TypeScript import a Python module's default export: ```javascript // main.mjs import mod from "./mod.py"; console.log(mod.hello()); ``` ```bash elide --interop run main.mjs ``` Without `--interop`, these calls fail. See [Languages and Interop](https://elide.help/docs/languages). ## Third-party packages Elide does not install PyPI packages: `elide install` skips `dependencies.pypi`, and `elide install --ecosystems=pypi` exits `2`. To load packages from a Python 3.13 virtual environment, set `VIRTUAL_ENV`: ```bash export VIRTUAL_ENV=/path/to/venv elide python app.py ``` Elide reads the environment's `lib/python3.13/site-packages`. See [Packages and virtual environments](https://elide.help/docs/python-packages); for unittest and pytest, see [Python tests](https://elide.help/docs/python-testing). ## Tracing and metrics The `opentelemetry` API and `logging` export traces, metrics, and logs through Elide, with no SDK installed; see [OpenTelemetry in Python](https://elide.help/docs/opentelemetry/python). ## Known limitations - **C extensions**: some C extension modules do not load. - **macOS**: native module isolation is not available. - **WebAssembly SIMD**: installing Python disables it; see [WebAssembly with Elide](https://elide.help/docs/wasm#limits). - **CPython differences**: some edge cases behave differently from CPython 3.13; see the [Compatibility Matrix](https://elide.help/docs/compatibility). ## 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) - [Python script](https://elide.help/docs/code-samples#python-script) --- # Java and Kotlin with Elide URL: https://elide.help/docs/jvm > Run Java and Kotlin source files with Elide, use the bundled JDK 25 and Kotlin tools, resolve Maven dependencies, and build and test a project. Elide compiles, formats, builds, and tests Java (up to JDK 25) and Kotlin (2.5.0-Beta1), and resolves Maven dependencies. > [!TIP] No JDK to install > The JDK and Kotlin tools ship with Elide; no separate JDK, Kotlin compiler or build tool is needed. ## Run a source file A file with a `main` entrypoint compiles and runs directly: ```bash elide run Hello.java elide run Hello.kt ``` ## Use individual tools `elide java`, `elide javac`, `elide kotlinc`, and `elide jar` work like the tools they name. Arguments go after `--`: ```bash elide javac -- -d target src/main/java/app/Main.java elide kotlinc -- -d target src/main/kotlin/app/Main.kt elide java -- -cp target app.Main ``` `elide format` formats Java with Google Java Format and Kotlin with ktfmt: ```bash elide format -- src # rewrite files elide format --list-files -- --dry-run src # list files that would change; exit 1 if any ``` ## Start a project ```bash elide init --plain --skip-defaults --template java ``` | Template | Creates | | --- | --- | | `java` | A Java project. | | `ktjvm` | A Kotlin project. | | `workspace` | A Kotlin library and an app that depends on it. | To migrate a Maven or Gradle project, `elide adopt` runs an AI coding agent; see [Adopt an Existing Project](https://elide.help/docs/toolchain/usage/adopt). ## Build a project ```bash elide install # resolve Maven dependencies elide build # compile and assemble artifacts elide test # run JUnit tests elide run # run the project's main class ``` Elide projects — build, run, and reuse cached work `elide build --inspect` lists the project's tasks. Manifest: [Project setup](https://elide.help/docs/projects). Compiler and packaging options: [JVM Toolchain](https://elide.help/docs/toolchain/jvm). ## What programs can use The JDK, the Kotlin standard library, bundled kotlinx libraries, JUnit for tests, and Elide's annotations; there is no Elide runtime API and no calls into JavaScript or Python. See [JVM APIs](https://elide.help/docs/api-jvm). For a database, add its JDBC driver as a Maven dependency ([Databases](https://elide.help/docs/api-database#other-languages)); to share a library, see [Maven publishing](https://elide.help/docs/toolchain/jvm/publishing). ## Tracing and metrics Java and Kotlin programs that Elide runs get no OpenTelemetry API, agent, or trace context from Elide. Add the OpenTelemetry Java SDK or agent to the program as on any JVM. `elide build` and `elide test` still export their own spans; see [OpenTelemetry](https://elide.help/docs/opentelemetry#languages). ## Rewrite and inspect code For projects with `elide.pkl`, [OpenRewrite](https://elide.help/docs/toolchain/jvm/rewrite) previews and applies Java recipes, and the [dependency code index](https://elide.help/docs/toolchain/jvm/code-index) finds class origins, inspects members, and queries compiled Java and Kotlin references. Both are experimental in 1.6.0. ## Samples - [Java records and streams](https://elide.help/docs/code-samples#java-records-and-streams) - [Kotlin collections](https://elide.help/docs/code-samples#kotlin-collections) - [Kotlin tests](https://elide.help/docs/code-samples#kotlin-tests) - [Kotlin coroutines](https://elide.help/docs/code-samples#kotlin-coroutines) - [Java with a Maven dependency](https://elide.help/docs/code-samples#java-with-a-maven-dependency) Start from a template: ```bash elide init --template java # Java app with a JUnit test elide init --template ktjvm # Kotlin app with a test elide init --template workspace # Kotlin library and app in one workspace ``` --- # WebAssembly with Elide URL: https://elide.help/docs/wasm > Run WASI command modules with Elide, map host directories, load WebAssembly libraries from JavaScript and TypeScript, and check supported proposals. WebAssembly support is experimental in 1.6.0. | You have | Use | Result | | --- | --- | --- | | A WASI command | `elide run app.wasm` | Runs the module with WASI Preview 1 imports. | | A WASM library | The `WebAssembly` API or an ES module import from JS/TS | Exposes the module's exports. | elide app.wasm — WASI commands and WASM libraries from JavaScript To compile Java or Kotlin to WebAssembly, see [WebImage](https://elide.help/docs/toolchain/jvm/webimage); its output needs its JavaScript loader, not `elide run`. Target guides: [Browser WASM](https://elide.help/docs/toolchain/web/wasm) and [Edge WASM](https://elide.help/docs/toolchain/edge/wasm). ## Run a WASM file ```bash elide run app.wasm elide app.wasm elide run app.wasm -- first second # program arguments elide run --timeout=5s app.wasm # exit 124 after 5 seconds ``` Elide calls the exported `_start`, or `_main` if `_start` is absent. Load a module with neither from JavaScript. | Behavior | Value | | --- | --- | | Argument zero | The module's absolute path. | | Exit status | Set by WASI `proc_exit`, not by a function's return value. | | Traps, malformed binaries | Nonzero exit. | | `--timeout` | Covers instantiation and execution; exits `124`. | ### Project entrypoints Set the module as the entrypoint in `elide.pkl`, then run `elide run`: ```pkl amends "elide:project.pkl" name = "wasm-app" entrypoint { "app.wasm" } ``` See [Project setup](https://elide.help/docs/projects). ## WASI Commands get WASI Preview 1 imports under `wasi_snapshot_preview1`: standard streams, arguments, exit status, and filesystem operations. Libraries loaded from JavaScript do not get WASI. ### Directory access WASI commands see no host directories until you map one: ```bash elide -Xpolyglot.wasm.WasiMapDirs=work::./data run app.wasm ``` This maps `./data` to the guest directory `work`. Separate mappings with commas: `work::./data,output::./results`. The sandbox still applies. WASI file opens need read and write permission, even for reads: ```bash elide -Xpolyglot.wasm.WasiMapDirs=work::./data run \ --sandbox --allow-read=./data --allow-write=./data app.wasm ``` See [Sandbox and Limits](https://elide.help/docs/sandbox). ## JavaScript and TypeScript interop The global `WebAssembly` API needs no flag: ```javascript import { readFile } from "node:fs/promises"; const bytes = await readFile(new URL("./math.wasm", import.meta.url)); const { instance } = await WebAssembly.instantiate(bytes, {}); console.log(instance.exports.add(20, 22)); ``` Modules loaded from JavaScript do not run `_start` or `_main`. The second argument supplies the module's imports: ```javascript const imports = { env: { log: (value) => console.log(value) } }; const { instance } = await WebAssembly.instantiate(bytes, imports); ``` The API includes `validate`, `compile`, `Module`, `Instance`, `Memory`, `Table`, `Global`, and import and export inspection. A compiled `Module` can be instantiated more than once. File reads follow the usual permissions. ### ES module imports ```javascript import { add } from "./math.wasm"; console.log(add(20, 22)); ``` ```javascript const math = await import("./math.wasm"); console.log(math.add(20, 22)); ``` Specifiers can be paths, `file:` URLs, or package exports that resolve to `.wasm`. A source-phase import returns the compiled module to instantiate yourself: ```javascript import source mathModule from "./math.wasm"; const math = await WebAssembly.instantiate(mathModule, {}); console.log(math.exports.add(20, 22)); ``` ## Supported WebAssembly proposals On by default, for commands and JS/TS interop: - Mutable globals and sign-extension operators - Non-trapping float-to-integer conversions - Multi-value function and block results - Bulk memory operations and reference types - Multiple memories - Extended constant expressions - Exception handling - Typed function references - Garbage-collected types (WasmGC) - Tail calls - Fixed-width SIMD (`v128`) and relaxed SIMD, except with Python installed Off by default: | Proposal | Option | Notes | | --- | --- | --- | | Memory64 | `wasm.Memory64` | Also requires `wasm.UseUnsafeMemory`. | | Threads and atomics | `wasm.Threads` | No WASI thread-spawning host API is supplied. | | Wide integer arithmetic | `wasm.WideArithmetic` | Separate from ordinary `i64` arithmetic. | | Legacy exception handling | `wasm.LegacyExceptions` | The newer exception-handling proposal is on by default. | Enable one with `-Xpolyglot.