Chapter 1: What is HolyPHP?
Understanding HolyPHP
HolyPHP is a low-level, compiled programming language with the soul of PHP. It combines the familiar, easy-to-learn syntax of PHP with the safety and performance of compiled languages like Rust and C.
Think of it this way: if you know PHP, you'll feel right at home. If you've ever wished PHP was faster, safer, or could compile to a standalone executable, HolyPHP is what you're looking for.
Key Features
๐ PHP Familiar
Uses $variables, looks like PHP, has 305 compatible built-in functions
โก Compiled to Native Code
Compiles directly to machine code, no interpreter or VM. Fast like C!
๐ Memory Safe
Compile-time borrow checker prevents memory errors, use-after-free, and data races
๐ฆ Standalone Executables
One command produces a single .exe with everything bundled
๐ฏ Ownership & Borrowing
Rust-inspired memory model without garbage collection
๐ ๏ธ Batteries Included
Built-in GUI, HTML/CSS engine, threading, async, WebSocket libraries
How Does It Work?
HolyPHP goes through a complete compilation pipeline:
source .hphp โ lexer โ parser โ type & borrow checker โ native binary
The entire toolchain is one self-contained hphp binary. It embeds its own runtime and libraries, so you don't need to install dependencies. When you compile, you get a native executable that runs anywhere (on the same platform) with no runtime required.
HolyPHP vs PHP
| Feature | PHP | HolyPHP |
|---|---|---|
| Execution | Interpreted by Zend Engine | Compiled to native machine code |
| Performance | Slower | ~25x faster than PHP 8 (in benchmarks) |
| Memory Safety | Runtime errors possible | Compile-time borrow checker |
| Distribution | Needs PHP runtime installed | Single standalone executable |
| Type System | Dynamic, optional types | Dynamic by default, strong when typed + ownership |
| Concurrency | Limited | Real OS threads with channels |
| GUI | Not built-in | Native Win32 GUI library included |
HolyPHP vs Rust
| Feature | Rust | HolyPHP |
|---|---|---|
| Learning Curve | Steep | Easier if you know PHP |
| Syntax | Unique, heavy on keywords | PHP-style, familiar |
| Ownership | Strict, everywhere | Rust-inspired but PHP-friendly |
| Macros/Templates | Complex | Simpler |
| Time to "Hello World" | Longer setup | Immediate |
When Should You Use HolyPHP?
- Fast CLI tools - Compile to a single executable, no PHP needed
- Desktop applications - Use the built-in
uilibrary for native GUIs - Performance-critical scripts - Get C-like speed with PHP-like syntax
- Learning systems programming - Learn ownership/borrowing in a gentler way
- Safe concurrent programs - Real threads with compile-time safety
Show a hint
Take one small step at a time. Follow the instructions above, write down the result you expect, and compare it with what your terminal or Playground shows. If a command fails, check the filename and that you opened a new terminal after installation.