Examples
Example Applications
Real-world applications written entirely in Jda, demonstrating the language’s capabilities for production use. Each compiles to a static binary under 1.1 MB with zero external dependencies.
- jda-grep – A high-performance text search tool (561 lines)
- jda-httpd – A minimal HTTP/1.1 server using raw syscalls (450 lines)
- jda-ml-demo – Neural network training benchmark, 37x faster than Python (486 lines)
jda-grep
A high-performance text search tool – Jda’s first real application. Demonstrates CLI argument parsing, file I/O, pattern matching, and ANSI color output, all using Jda’s standard library.
Features
- Pattern matching (substring search)
- Case-insensitive search (
-i) - Line numbers (
-n) - Match count (
-c) - Invert match (
-v) - List matching files only (
-l) - Multi-file search with filename prefixes
- Stdin piping support
- ANSI color output (disable with
--no-color) - Combined short flags (
-ni,-cv, etc.) - Proper exit codes (0 = match found, 1 = no match, 2 = error)
Build
bash apps/build-grep.shUsage
# Search for pattern in file
./apps/jda-grep error log.txt
# Case-insensitive with line numbers
./apps/jda-grep -ni TODO main.jda
# Count matches across multiple files
./apps/jda-grep -c "fn " stdlib/*.jda
# List files containing pattern
./apps/jda-grep -l bug *.jda
# Pipe from stdin
cat server.log | ./apps/jda-grep "500 Internal"
# Show non-matching lines
./apps/jda-grep -v "^;" config.jdaBinary Size
~1.05 MB static ELF binary. Zero external dependencies.
jda-httpd
A minimal HTTP/1.1 server written in Jda. Pure syscalls, zero libc. Demonstrates socket programming, string parsing, and HTTP protocol handling.
Features
- HTTP/1.1 GET request handling
- Route-based dispatch with multiple endpoints
- Query string parsing
- Server uptime and request counting
- Fibonacci computation endpoint
- Echo endpoint
- Pure Linux syscalls (no libc, no external dependencies)
Supported Routes
| Route | Description |
|---|---|
GET / | Welcome page with links to all endpoints |
GET /hello | “Hello from Jda!” |
GET /status | Server stats (uptime, requests served) |
GET /echo?msg=... | Echoes query string |
GET /fib?n=... | Computes fibonacci(n) |
| Everything else | 404 Not Found |
Build
bash apps/build-httpd.shUsage
# Start on default port 8080
./apps/jda-httpd
# Start on custom port
./apps/jda-httpd 3000
# Test with curl
curl http://localhost:8080/hello
curl http://localhost:8080/fib?n=30
curl http://localhost:8080/echo?msg=hello+world
curl http://localhost:8080/statusBinary Size
~1 MB static ELF binary. Zero external dependencies.
jda-ml-demo
Neural network training benchmark – Jda vs Python head-to-head comparison. Trains MLPs from scratch with no external dependencies on either side. Jda is up to 37x faster than Python.
Tasks
| # | Task | Architecture | Epochs |
|---|---|---|---|
| 1 | XOR Classification | 2->8->1 MLP | 5,000 |
| 2 | Sine Approximation | 1->16->1 MLP | 10,000 |
| 3 | Matrix Multiply | 64x64 matmul | 10 iters |
Performance (x86-64 Linux, best of 3)
| Task | Jda | Python (no NumPy) | Speedup |
|---|---|---|---|
| XOR training (5K epochs) | 21 ms | 778 ms | ~37x |
| Sine training (10K epochs) | 439 ms | 15,347 ms | ~35x |
| 64x64 matmul (per iter) | 3 ms | 75 ms | ~25x |
Both implementations use identical algorithms (same loop structure, same SGD, same loss function). The only difference is the runtime: Jda compiles to native x86-64 machine code, Python interprets through CPython.