Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 23 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# ChadScript

As fast as C, as ergonomic as TypeScript.
TypeScript, compiled to native code.

ChadScript compiles TypeScript to native binaries. No Node.js, no V8, no runtime. Sub-2ms startup, ~250KB binaries.
ChadScript compiles a statically analyzable subset of TypeScript to native machine code via LLVM — the same backend behind C, Rust, and Swift. No VM, no interpreter, no runtime. The output is a standalone binary: sub-millisecond startup, ~250KB, zero dependencies.

The compiler is self-hosting and the only dependency is itself. Install with curl, not npm.

**Status: Beta** — self-hosting, 621+ tests, used in [production](https://chadsmith.dev/weather).

**[Docs](https://cs01.github.io/ChadScript/getting-started/installation)** · **[Standard Library](https://cs01.github.io/ChadScript/stdlib/)** · **[Language Features](https://cs01.github.io/ChadScript/language/features)** · **[Benchmarks](https://cs01.github.io/ChadScript/benchmarks)**

---

## Install
Expand Down Expand Up @@ -69,61 +71,35 @@ Hono-style API, C-level performance. One binary, no node_modules. See [`examples

## Benchmarks

Compared against C, Go, Node.js, and Bun on Ubuntu (CI):
ChadScript compiles through LLVM, the same backend behind C and Rust — so it gets the same optimization passes. Compared against C, Go, Node.js, and Bun on Ubuntu (CI):

| Benchmark | C | ChadScript | Go | Node | Bun |
| -------------- | ------ | ---------- | ------ | ------ | ------ |
| Cold Start | 0.6ms | **0.6ms** | 1.3ms | 21.8ms | 7.6ms |
| Monte Carlo Pi | 0.400s | **0.398s** | 0.405s | 1.474s | 6.428s |
| Fibonacci | 0.725s | **1.424s** | 1.429s | 2.842s | 1.837s |
| JSON Parse | 0.004s | **0.005s** | 0.016s | 0.015s | 0.007s |
| N-Body Sim | 1.453s | **1.852s** | 1.964s | 2.296s | 2.817s |
| Benchmark | ChadScript | Node.js | vs Node | C |
| -------------- | ---------- | ------- | -------- | ------ |
| Cold Start | **0.6ms** | 21.8ms | **36x** | 0.6ms |
| Monte Carlo Pi | **0.398s** | 1.474s | **3.7x** | 0.400s |
| File I/O | **0.089s** | 0.315s | **3.5x** | 0.088s |
| JSON Parse | **0.005s** | 0.015s | **3.0x** | 0.004s |
| Fibonacci | **1.424s** | 2.842s | **2.0x** | 0.725s |
| Sieve | **0.038s** | 0.054s | **1.4x** | 0.027s |
| N-Body Sim | **1.852s** | 2.296s | **1.2x** | 1.453s |
| Quicksort | **0.202s** | 0.249s | **1.2x** | 0.170s |
| SQLite | **0.374s** | 0.437s | **1.2x** | 0.314s |

Updated on every PR. [Source](https://github.com/cs01/ChadScript/tree/main/benchmarks)
[Full benchmarks with Go and Bun](https://cs01.github.io/ChadScript/benchmarks) (updated on every PR)

---

## How it works

```bash
chad run app.ts # compile + run in one step — no build config, no install
chad build app.ts # or compile to a standalone binary
```

Every type is resolved at compile time. The compiler optimizes your code the same way C and Rust compilers do. `chad run` compiles and executes in one step — no build step, no install process, no config files. When you want a deployable binary, `chad build` produces a single native executable.

---
## It's Fast

## Why TypeScript syntax?
Your code goes through the same LLVM optimization passes as C and Rust — not a JIT, not an interpreter. 0.8ms cold start, native execution speed.

TypeScript is familiar to millions of developers, and LLMs generate it fluently. ChadScript uses a statically-typed subset where every type is resolved at compile time — no `any`, no runtime type checks, no surprises:
## It's Familiar

- **Null safety** — `string` is never null. Use `string | null` and `?.` for optional values.
- **No manual memory management** — automatic garbage collection. No use-after-free, no double-frees.
- **Compile-time error catching** — type mismatches, invalid method calls, and unsafe patterns are caught before your code runs.
- **C interop** — call any C library directly with `declare function`. No wrappers, no overhead.
- **IDE support** — `chad init` generates `tsconfig.json` with ChadScript types. VS Code works out of the box.
Classes, interfaces, generics, async/await, closures, destructuring, template literals, JSX, `for...of`, `Map`, `Set`, `Promise.all` — it's the TypeScript you already write. No new syntax, no new mental model.

---
## It's Friendly

## What's included

No `npm install`. Everything ships with the compiler:

| Module | What it does |
| --------------------- | ------------------------ |
| `fetch` | HTTP client |
| `Router`, `httpServe` | HTTP server with routing |
| `fs` | File system |
| `sqlite` | Embedded database |
| `crypto` | Hashing, random bytes |
| `JSON` | Typed parse/stringify |
| `child_process` | Spawn subprocesses |
| `WebSocket` | WebSocket server |
| `Map`, `Set` | Hash map and set |
| `RegExp` | Regular expressions |
| `console` | Prints any type |
| `ArgumentParser` | CLI argument parsing |
No `npm install`. Everything ships with the compiler: HTTP server, SQLite, fetch, crypto, WebSocket, JSON, filesystem, regex, child processes, argument parsing. Write your code, compile it, ship a single binary.

---

Expand All @@ -150,4 +126,3 @@ See [`examples/cli-tools/`](examples/cli-tools/) for a suite of Unix tool replac
- [Quickstart](https://cs01.github.io/ChadScript/getting-started/quickstart)
- [Supported Features](https://cs01.github.io/ChadScript/language/features)
- [Standard Library](https://cs01.github.io/ChadScript/stdlib/)
- [FAQ](https://cs01.github.io/ChadScript/faq)
11 changes: 10 additions & 1 deletion benchmarks/assemble_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@
continue
lang, value, label = parts[0], parts[1], parts[2]
try:
results[lang] = {"value": round(float(value), 3), "label": label}
rounded = round(float(value), 3)
meta_info = META.get(bkey, {"metric": "s"})
metric = meta_info.get("metric", "s")
if metric == "ms":
clean_label = f"{rounded}ms"
elif metric in ("req/s", "msg/s"):
clean_label = f"{int(rounded)} {metric}"
else:
clean_label = f"{rounded:.3f}s"
results[lang] = {"value": rounded, "label": clean_label}
except ValueError:
continue
if lang == "chadscript":
Expand Down
140 changes: 76 additions & 64 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,84 @@ export default defineConfig({
},

nav: [
{ text: 'Getting Started', link: '/getting-started/installation' },
{ text: 'Fundamentals', link: '/language/features' },
{ text: 'Reference', link: '/stdlib/' },
{ text: 'GitHub', link: 'https://github.com/cs01/ChadScript' }
{ text: 'Docs', link: '/getting-started/installation' },
{ text: 'Standard Library', link: '/stdlib/' },
{ text: 'Benchmarks', link: '/benchmarks' },
],

sidebar: [
{
text: 'Getting Started',
items: [
{ text: 'What is ChadScript?', link: '/why-chadscript' },
{ text: 'Installation', link: '/getting-started/installation' },
{ text: 'Quickstart', link: '/getting-started/quickstart' },
{ text: 'IDE Setup', link: '/getting-started/ide-setup' },
]
},
{
text: 'Fundamentals',
items: [
{ text: 'Language', link: '/language/features' },
{ text: 'How It Works', link: '/language/architecture' },
{ text: 'FFI', link: '/language/ffi' },
{ text: 'Debugging', link: '/getting-started/debugging' },
]
},
{
text: 'Reference',
items: [
{ text: 'CLI', link: '/getting-started/cli' },
{ text: 'Type Mappings', link: '/language/type-mappings' },
{
text: 'Standard Library',
collapsed: true,
items: [
{ text: 'Overview', link: '/stdlib/' },
{ text: 'Array Methods', link: '/stdlib/array' },
{ text: 'Async', link: '/stdlib/async' },
{ text: 'ChadScript.embed', link: '/stdlib/embed' },
{ text: 'child_process', link: '/stdlib/child-process' },
{ text: 'console', link: '/stdlib/console' },
{ text: 'crypto', link: '/stdlib/crypto' },
{ text: 'Date', link: '/stdlib/date' },
{ text: 'fetch', link: '/stdlib/fetch' },
{ text: 'fs', link: '/stdlib/fs' },
{ text: 'HTTP Server / Router', link: '/stdlib/http-server' },
{ text: 'JSON', link: '/stdlib/json' },
{ text: 'Map', link: '/stdlib/map' },
{ text: 'Math', link: '/stdlib/math' },
{ text: 'Number', link: '/stdlib/number' },
{ text: 'Object', link: '/stdlib/object' },
{ text: 'os', link: '/stdlib/os' },
{ text: 'path', link: '/stdlib/path' },
{ text: 'process', link: '/stdlib/process' },
{ text: 'RegExp', link: '/stdlib/regexp' },
{ text: 'Set', link: '/stdlib/set' },
{ text: 'sqlite', link: '/stdlib/sqlite' },
{ text: 'String Methods', link: '/stdlib/string' },
{ text: 'Syscalls', link: '/stdlib/syscalls' },
{ text: 'Test Runner', link: '/stdlib/test-runner' },
{ text: 'tty', link: '/stdlib/tty' },
{ text: 'Uint8Array', link: '/stdlib/uint8array' },
]
},
]
},
],
sidebar: {
'/': [
{
text: 'Getting Started',
items: [
{ text: 'Installation', link: '/getting-started/installation' },
{ text: 'Quickstart', link: '/getting-started/quickstart' },
{ text: 'IDE Setup', link: '/getting-started/ide-setup' },
]
},
{
text: 'Language',
items: [
{ text: 'Features', link: '/language/features' },
{ text: 'Debugging', link: '/getting-started/debugging' },
]
},
{
text: 'CLI',
items: [
{ text: 'Commands', link: '/getting-started/cli' },
]
},
{
text: 'Standard Library',
link: '/stdlib/',
},
{
text: 'Advanced',
items: [
{ text: 'FFI', link: '/language/ffi' },
{ text: 'How It Works', link: '/language/architecture' },
{ text: 'Type Mappings', link: '/language/type-mappings' },
]
},
],
'/stdlib/': [
{
text: 'Standard Library',
items: [
{ text: 'Overview', link: '/stdlib/' },
{ text: 'Array', link: '/stdlib/array' },
{ text: 'Async', link: '/stdlib/async' },
{ text: 'child_process', link: '/stdlib/child-process' },
{ text: 'console', link: '/stdlib/console' },
{ text: 'crypto', link: '/stdlib/crypto' },
{ text: 'Date', link: '/stdlib/date' },
{ text: 'embed', link: '/stdlib/embed' },
{ text: 'encoding', link: '/stdlib/encoding' },
{ text: 'fetch', link: '/stdlib/fetch' },
{ text: 'fs', link: '/stdlib/fs' },
{ text: 'HTTP Server', link: '/stdlib/http-server' },
{ text: 'JSON', link: '/stdlib/json' },
{ text: 'Map', link: '/stdlib/map' },
{ text: 'Math', link: '/stdlib/math' },
{ text: 'Number', link: '/stdlib/number' },
{ text: 'Object', link: '/stdlib/object' },
{ text: 'os', link: '/stdlib/os' },
{ text: 'path', link: '/stdlib/path' },
{ text: 'process', link: '/stdlib/process' },
{ text: 'RegExp', link: '/stdlib/regexp' },
{ text: 'Set', link: '/stdlib/set' },
{ text: 'sqlite', link: '/stdlib/sqlite' },
{ text: 'String', link: '/stdlib/string' },
{ text: 'Syscalls', link: '/stdlib/syscalls' },
{ text: 'Test Runner', link: '/stdlib/test-runner' },
{ text: 'tty', link: '/stdlib/tty' },
{ text: 'Uint8Array', link: '/stdlib/uint8array' },
{ text: 'URL', link: '/stdlib/url' },
]
},
],
},

socialLinks: [
{ icon: 'github', link: 'https://github.com/cs01/ChadScript' }
Expand Down
6 changes: 5 additions & 1 deletion docs/.vitepress/theme/HeroBenchmarks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ const activeBench = computed(() => benchmarks.value[activeIndex.value])
const entries = computed(() => {
const b = activeBench.value
if (!b) return []
const langOrder = ['c', 'chadscript', 'go', 'bun', 'node']
const langOrder = ['c', 'chadscript', 'go', 'bun', 'node', 'grep', 'ripgrep', 'xxd']
const known = new Set(langOrder)
const sorted = langOrder
.filter(k => k in b.results)
.map(k => ({ key: k, ...b.results[k] }))
for (const k of Object.keys(b.results)) {
if (!known.has(k)) sorted.push({ key: k, ...b.results[k] })
}
if (b.lower_is_better) {
sorted.sort((a, b2) => a.value - b2.value)
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/IRShowcase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ onUnmounted(() => {
<p class="cta-tagline">No build step. No install. Just <code>chad run yourfile.ts</code> and it compiles + runs instantly.</p>
<div class="cta-buttons">
<a href="/ChadScript/getting-started/installation" class="cta-link">Get Started</a>
<a href="/ChadScript/why-chadscript" class="cta-link secondary">What is ChadScript?</a>
<a href="/ChadScript/language/features" class="cta-link secondary">Language Features</a>
</div>
</div>
</div>
Expand Down
Loading
Loading