Cloudflare Computer Programming Languages: Complete Runtime Type Guide
Cloudflare Computer supports three programming languages across its runtime types: Shell (POSIX/Bash), Just-bash (minimal Bash interpreter), and ECMAScript modules (JavaScript).
Modern development workflows demand flexibility in how code executes. Cloudflare Computer meets this need through three distinct runtime backends, each optimized for specific execution scenarios. This article examines the Cloudflare Computer programming languages available through workspace.runtime.exec, their technical implementations, and practical usage patterns drawn directly from the source code.
Runtime Backends and Supported Languages
Cloudflare Computer organizes its language support through backend-specific interpreters. The mapping between backend identifiers and programming languages is defined in docs/16_code_execution.md (lines 16-21) and implemented across the runtime system.
container-shell: Full POSIX/Bash Shell
The container-shell backend provides unrestricted Linux shell execution. This backend accepts standard Shell commands and can invoke any native binary installed in the container environment.
Key characteristics:
- Full Linux container with native package ecosystem
- Supports complex command pipelines and shell scripting
- Ideal for build processes, package management, and system administration
worker-shell: Just-bash Minimal Interpreter
The worker-shell backend implements a lightweight Just-bash interpreter. This stripped-down Bash-like runtime prioritizes speed and safety for text-processing operations.
Key characteristics:
- Fast startup for text-tool commands
- Built-in Workspace Git implementation
- No full container overhead
According to the source in docs/16_code_execution.md, this backend specifically powers "the built-in Workspace Git implementation" for version control operations.
worker-javascript: ECMAScript Modules
The worker-javascript backend executes ECMAScript modules in an isolated JavaScript environment. This backend supports modern JavaScript patterns including dynamic imports and Node.js-compatible APIs.
Key characteristics:
- Full module resolution with
importstatements - Access to
node:fs/promisesfor filesystem operations - Trusted
ws:*capability system for secure Workspace interactions
Execution Architecture
Backend selection occurs at runtime through the backend option in WorkspaceRuntimeExecOptions, defined in packages/computer/src/runtime/types.ts. The routing logic in packages/computer/src/workspace.ts forwards execution requests to the appropriate interpreter based on this selection.
As documented in docs/16_code_execution.md (lines 5-10), all three backends share a consistent API surface while interpreting the source parameter according to their respective languages.
Code Examples by Programming Language
Shell Execution with container-shell
const handle = await workspace.runtime.exec(
"apt-get update && apt-get install -y curl",
{ backend: "container-shell", cwd: "/workspace", encoding: "utf8" }
);
const result = await handle.result();
console.log(result.stdout);
This example demonstrates full Linux container access, including package manager operations unavailable in restricted backends.
Just-bash Execution with worker-shell
const handle = await workspace.runtime.exec(
"git status",
{ backend: "worker-shell", encoding: "utf8" }
);
const result = await handle.result();
console.log(result.stdout);
The lightweight interpreter excels at Git operations and text processing without container startup overhead.
JavaScript Module Execution with worker-javascript
const handle = await workspace.runtime.exec(
`export default async function () {
const { readFile } = await import("node:fs/promises");
const data = await readFile("/workspace/data.json", "utf8");
return JSON.parse(data);
}`,
{ backend: "worker-javascript", encoding: "utf8" }
);
const result = await handle.result();
console.log(result.value); // Parsed JSON object
JavaScript execution supports full module semantics including default exports, dynamic import(), and structured return values via result.value.
Implementation Files
Understanding the Cloudflare Computer programming language support requires familiarity with these key files:
| File | Purpose |
|---|---|
docs/16_code_execution.md |
Documents the three backends and language mappings (lines 16-21) |
packages/computer/src/runtime/types.ts |
Defines WorkspaceRuntimeExecOptions with backend field |
packages/computer/src/workspace.ts |
Implements backend routing logic |
examples/worker-shell/src/index.ts |
Reference implementation for Just-bash usage |
examples/worker-javascript/src/index.ts |
Reference implementation for JavaScript module usage |
Selecting the Right Programming Language
Choose your Cloudflare Computer programming language based on execution requirements:
- Shell (
container-shell) — Required for native binaries, package installation, or complex shell pipelines - Just-bash (
worker-shell) — Optimal for Git operations and fast text processing without container overhead - JavaScript (
worker-javascript) — Preferred for structured data manipulation, API interactions, and module-based code organization
Summary
- Cloudflare Computer programming languages encompass Shell, Just-bash, and ECMAScript through three distinct backends
- Backend selection via the
backendoption inworkspace.runtime.execdetermines how thesourceparameter is interpreted - container-shell provides full Linux environment access for unrestricted execution
- worker-shell delivers optimized performance for text tools and Git operations
- worker-javascript enables modern JavaScript development with module support and Node.js-compatible APIs
- All backends share consistent TypeScript APIs while targeting different execution models
Frequently Asked Questions
How do I choose between worker-shell and container-shell for bash commands?
worker-shell runs a minimal Just-bash interpreter optimized for speed with no container overhead—ideal for Git commands and text processing. container-shell launches a full Linux container capable of running any installed binary. Choose worker-shell for milliseconds-scale Git operations; use container-shell when you need package managers, compiled binaries, or system utilities.
Can I import npm packages in worker-javascript?
The worker-javascript backend supports ECMAScript modules with import statements and Node.js built-ins like node:fs/promises. The source code shows dynamic imports working with standard Node.js APIs. Third-party npm packages would need to be bundled or available through the Workspace capability system, as the isolated runtime does not perform npm installation during execution.
Is there a Python or other language runtime?
Based on the source analysis of docs/16_code_execution.md and packages/computer/src/runtime/types.ts, Cloudflare Computer currently supports only three programming languages: Shell (POSIX/Bash), Just-bash, and ECMAScript modules. No Python, Ruby, or other language backends are documented in the official runtime type definitions.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →