Express on Osprey: the TypeScript flavor, measured against Node.js
@osprey/express is Express 5 ported to Osprey's TypeScript flavor. Express applications compile to a native binary; Node.js never runs. The film serves the Express README example, requests it, runs Express's own web-service example and changes a reply.
Serve the Express README example
This is the example from the Express 5.3.0 README, unchanged. It is examples/hello-world/index.ts:
import express from 'express'
const app = express()
app.get('/', (req, res) => {
res.send('Hello World')
})
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000')
})
From a checkout of the repository, compile and serve it, then request it from a second terminal:
make build
target/release/osprey src/osprey/packages/express/examples/hello-world --run
curl -i http://127.0.0.1:3000/
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 11
Connection: keep-alive
Keep-Alive: timeout=5
Hello World
The project's osprey.toml lists its TypeScript files, so the compiler claims only those:
[project]
name = "express-hello-world"
source_roots = [".", "../../src"]
typescript_sources = ["../../src/express.ts", "index.ts"]
entry = "index.ts"
The package's end-to-end test compares 164 replies from four example applications with what Express 5.3.0 sent: status line, body and the headers Express sets. ETag and Date are not sent yet (issue 398).
Supported: routing and :name parameters, req.params, req.query, req.get, JSON bodies through jsonBody(req), middleware with app.use and req.next(), error handlers, express.Router() mounted with app.mount, res.status, res.set, res.send, res.json, app.listen and Express's 404 page.
Not yet: HEAD and OPTIONS handling, redirects, static files, ETag and Date, and overloads by parameter count such as app.use(handler) without a path.
Measure it against Express on Node.js
The bench serves each example three ways: Osprey with reference counting (ARC), Osprey with the tracing garbage collector (GC), and Express 5.3.0 on Node.js. Each server gets 1,000 warm-up requests and 10,000 timed ones, 16 in flight, a new connection per request, for five trials. Every reply is checked against Express's reply, so a wrong answer does not count.
Apple M4 Max, Node.js 24.19.0, 16 November 2026. Median of five trials: requests per second, then peak memory.
| Example | Osprey, ARC | Osprey, GC | Express on Node.js |
|---|---|---|---|
| hello-world | 24,260/s · 3 MiB | 19,888/s · 103 MiB | 25,736/s · 145 MiB |
| routes | 24,264/s · 3 MiB | 19,609/s · 108 MiB | 25,485/s · 146 MiB |
| web-service | 24,680/s · 3 MiB | 15,066/s · 214 MiB | 25,263/s · 126 MiB |
- Express is slightly faster. Osprey ARC answered 2 to 6 percent fewer requests per second. Its 95th-percentile latency was lower on two of three examples.
- Osprey uses far less memory. ARC peaked at 3 MiB; Node.js at 126 to 146 MiB.
- GC is the slowest. 23 percent behind Express on the small examples, 40 percent on web-service, which allocates a JSON reply per request.
- The examples are small. Osprey runs one handler at a time, so it does not yet use more than one core (issue 397).
The package README has latency figures. Run the bench yourself (it needs Node.js for the Express side):
(cd src/osprey/packages/express/oracle && npm ci)
make -C src/osprey/packages express-bench
Transcript
- This is Express, the web framework from Node.js, running on Osprey with no Node.js at all. We'll start with the measurement: the same Express application, served by Osprey and by real Express, under the same load.
- This is the comparison bench from the Express package. It takes three example applications and serves each one three ways: compiled by Osprey with the garbage collector, compiled by Osprey with reference counting, and run by real Express on Node.js.
- Each server gets the same requests over loopback, sixteen in flight at once: a thousand to warm up, then ten thousand that are timed. That is repeated for five trials, and the servers take turns, so a busy moment on the machine hits each of them alike.
- Every timed reply is checked against what Express answered, so a fast wrong answer does not count.
- And here is the table. Read the reference counting rows against the Node rows. Requests per second are within three percent of each other on every example, and neither side leads on all three. The last column is peak memory: three megabytes for Osprey with reference counting, and between a hundred and thirty and a hundred and fifty for Node.
- The garbage collected build is the slowest of the three, and on the web service example it uses the most memory. So this is not a claim that Osprey beats Express on speed. It is one machine, three small examples, and the numbers as they came out.
- Here's what is being measured. The first example is the application from the Express README, unchanged.
- Osprey compiles it ahead of time to a native binary.
- There is no Node.js in that binary, and no JavaScript engine.
- And every reply is compared with what real Express sends for the same file.
- This is the file. It imports express and creates an application.
- It registers one route. A GET request for the root path is answered with Hello World.
- Then it listens on port three thousand, and logs a line once the server is up.
- Now run it with Osprey. The compiler reads the TypeScript, checks the types, and warns that the request parameter is never used. Then it builds a native program and starts it. The line from the callback prints, and the process stays up, as it would under Node.
- In the second terminal, request the root path. The reply carries the status, the X-Powered-By header, the content type Express chooses for a string, and the body: Hello World.
- Now ask for a path that no route matches. Express has a final handler for that, and the port has it too. The server's log on the left records a four oh four, and the reply carries the security headers and the same small page, which says it cannot GET that path.
- How does the port work? It is written in the same TypeScript flavor. Calling express returns an application, which is a list of routes and a list of error handlers.
- Get takes the application, a path and a handler, and returns a new application with one more route. Nothing is mutated.
- With route appends a record of the method, the path and the handler to the list.
- The response is a record too. It holds the status, the body, the content type and the headers, and a signal that tells the dispatcher what to do with it.
- Status, set, send and json each return a new response with one thing changed. That is how a handler written as statements, or as a chain, builds the same reply.
- Listen starts the native HTTP listener with the application.
- If it started, the callback runs and the caller gets a listening server.
- If the port could not be bound, that is a value as well: the error is printed and returned. Osprey has no exceptions, so the failure cannot be skipped by accident.
- The third example is Express's own web service example, ported. This middleware is mounted on slash A P I. It reads the A P I key from the query string. With no key, it fails the request with a four hundred, and an error handler turns that into JSON.
- Run it, and ask for the users with a valid key. The middleware passes the request on, and the route answers with JSON.
- Ask again without a key. The reply is four hundred, Bad Request, with the error as JSON. In the tests, every one of these replies is compared with the original example running on real Express.
- Back to the bench for a moment, because the numbers only mean something with the method. Sixteen requests are in flight at a time.
- A thousand warm up each server, and ten thousand are timed.
- And each server runs five trials. The bench is one file in the package, so you can run it on your own machine.
- Now change it. In the README example, select the word World, and type Osprey. Save the file.
- Run it again. Osprey compiles the edited file and serves it. Request the root path, and the reply is the new text: Hello Osprey.
- Some limits. The port is in progress, and this film shows only what exists.
- There is no Router yet, and no JSON request bodies.
- Handlers do not yet run in parallel across cores, which is the next thing to fix for throughput.
- And under the garbage collector, the port is slower than Express today.
- To try it, serve the README example, request it with curl, and run the comparison bench yourself. The port's source is one file. Read it.