Language Comparisons
How Crush compares to other popular languages.
Crush vs Python
Similarities
- Simple, readable syntax
- Dynamic typing
- High-level abstractions
Differences
| Feature | Crush | Python |
|---|---|---|
| Polyglot | ✓ Embed multiple languages | ✗ Single language |
| Security | ✓ Capability-based | ✗ Full system access |
| Compilation | ✓ Compiles to bytecode | ✗ Interpreted |
| Type Hints | ✓ Optional | ✓ Optional (PEP 484) |
Example Comparison
Python:
def greet(name):
print(f"Hello, {name}!")
greet("Alice")
Crush:
fn greet(name: String) {
io.print("Hello, " + name + "!");
}
greet("Alice");
Crush vs JavaScript
Similarities
- Dynamic typing
- First-class functions
- Async support (future)
Differences
| Feature | Crush | JavaScript |
|---|---|---|
| Polyglot | ✓ | ✗ |
| Security | ✓ Capabilities | ✗ Node.js has full access |
| Syntax | Rust-like | C-like |
Crush vs Rust
Similarities
- Similar syntax
- Type hints
- Performance focus
Differences
| Feature | Crush | Rust |
|---|---|---|
| Type System | Dynamic | Static, strict |
| Memory Safety | VM-managed | Borrow checker |
| Polyglot | ✓ | ✗ |
| Compilation | To bytecode + AOT native | To native code |
| AOT Performance | Near-native via crush-aotc | Native |
Crush vs Bash
Similarities
- Scripting focus
- System administration
- Command execution
Differences
| Feature | Crush | Bash |
|---|---|---|
| Type System | ✓ Types | ✗ Everything is string |
| Polyglot | ✓ | ✗ |
| Syntax | Modern | Unix shell |
| Error Handling | Better | Limited |
Performance
Crush has five execution tiers spanning interpreter to native code:
| Tier | Speed vs CVM1 (simple) | Speed vs CVM1 (compute) |
|---|---|---|
| CVM1 (interpreter) | 1.0× | 1.0× |
| FastVM | 0.09× | 0.5× |
| AOT Rust (rustc) | 42× | 130× |
| AOT C (gcc -O3) | 54× | 317× |
| AOT C (clang -O3) | 55× | 378× |
AOT-compiled Crush achieves near-C performance — LLVM and GCC constant-fold
the stack machine operations into direct native code. For compute-bound Crush programs,
crush-aotc produces .so files that run within 2-5× of hand-written C.
See the crush-ast benchmarks for detailed cross-language comparisons.
When to Use Crush
✅ Use Crush when:
- You need to combine multiple languages
- Security and isolation are important
- You want capability-based permissions
- You’re building polyglot applications
- You need native performance with scripting ergonomics (
crush-aotc)
❌ Consider alternatives when:
- You have a large existing codebase in another language
- You need mature ecosystem (Python/JavaScript)
- You’re building web frontends (use JavaScript/TypeScript)
Migration Guide
From Python
- Add type hints to function signatures
- Replace
print()withio.print() - Add capability permissions to manifest
- Keep Python code in
@python {}blocks during transition
From JavaScript
- Change
functiontofn - Add semicolons
- Replace
console.log()withio.print() - Keep JavaScript in
@javascript {}blocks
From Bash
- Wrap shell commands in
@bash {}blocks - Use Crush for logic and control flow
- Add type safety with Crush variables