Each sample is one file; run it in an empty directory.
TypeScript
// discount.ts
interface Order {
price: number;
quantity: number;
}
const order: Order = { price: 79.99, quantity: 2 };
console.log(`$${(order.price * order.quantity).toFixed(2)}`);elide run discount.ts$159.98Embedded SQLite
// database.ts
import { Database } from "elide:sqlite";
const db = new Database();
db.exec("CREATE TABLE users (name TEXT)");
db.exec("INSERT INTO users VALUES ('Ada')");
console.log(db.query("SELECT name FROM users").get().name);elide run database.tsAdaHTTP handler
// server.ts
export default {
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url);
return Response.json({ path: url.pathname });
},
};elide serve --no-tui server.ts
curl http://127.0.0.1:8080/hello{"path":"/hello"}Kotlin
// Inventory.kt
data class Item(val name: String, val count: Int)
fun main() {
val items = listOf(Item("bolts", 120), Item("nuts", 80), Item("washers", 0))
val inStock = items.filter { it.count > 0 }.joinToString { it.name }
println("In stock: $inStock")
}elide run Inventory.ktIn stock: bolts, nutsPython calling JavaScript
Needs the Python component and --interop.
# interop.py
from elide import js
total = js("[1, 2, 3, 4].reduce((a, b) => a + b, 0)")
print(total)elide --interop python interop.py10JavaScript importing Python
Needs the Python component and --interop.
# greet.py
def hello():
return "Hello from Python"// main.mjs
import greet from "./greet.py";
console.log(greet.hello());elide --interop run main.mjsHello from Python