HP(河马编程语言)是一门零运行时、静态类型、中英双语关键字的系统级语言。像 Python 一样好写,像 C 一样快。 HP (Hippo Programming Language) is a zero-runtime, statically-typed systems language with bilingual (中文/English) keywords — as ergonomic as Python, as fast as C.
先做减法,实现一个极致精简、零运行时开销的静态核心;再通过标准库做加法。HP 把现代系统语言的强项发挥到极致。Subtract first, add later. HP strips to a minimal zero-cost static core, then grows through its standard library.
编译期求值、所有权检查、泛型单态化全部在编译期完成,二进制里没有解释器或虚拟机。CTFE, borrow-checking and monomorphization happen at compile time — no interpreter or VM in the binary.
fn/函数、if/如果 完全等价,可中英文混写,Token 层统一映射。fn/函数, if/如果 are identical — mix freely, unified at the token layer.
NLL 借用检查在编译期确定内存的分配与释放,无需 GC、无需引用计数。NLL borrow-checking decides allocation & deallocation at compile time — no GC, no refcount.
-O2/-O3 + LTO + SIMD,峰值性能比手写 C 高 5%–16x(向量化场景)。-O2/-O3 + LTO + SIMD deliver 5%–16x over hand-written C on vectorized workloads.
值语义、标签联合、编译期分派的接口(trait),运算符可重载。Value semantics, tagged unions, compile-time dispatched interfaces, overloadable operators.
macro 与 const fn(CTFE)在编译期展开代码、生成查找表、解析配置,零运行时开销。macro and const fn (CTFE) expand code, build lookup tables and parse config at compile time.
获取 hpc(当前支持 Windows x64),无需安装运行时。Grab hpc (Windows x64 for now) — no runtime to install.
用任意编辑器创建 hello.hp,语法像 Python 一样直白。Create hello.hp in any editor — the syntax is as direct as Python.
一条命令产出原生可执行文件,瞬间运行。One command produces a native executable that runs instantly.
module { "<std.io>" }
fn main() {
a: int = 1
b: int = 2
c: int = a + b
std.io.print("Hello HP!", c)
}
# 编译并运行(默认 -O2,产出 hello.exe)
$ hpc hello.hp
$ ./hello.exe
Hello HP! 3
| 能力Capability | HP | Python | Rust | C++ |
|---|---|---|---|---|
| 运行时开销Runtime overhead | 零zero | 解释器interpreter | 零zero | 零zero |
| 上手难度Learning curve | 低low | 低low | 高high | 高high |
| 中英双语关键字Bilingual keywords | ✓✓ | —— | —— | —— |
| 所有权系统Ownership | ✓ move✓ move | —— | ✓✓ | 手动manual |
| 编译期求值CTFE | ✓✓ | —— | ✓✓ | —— |
| 峰值性能Peak perf | C 级C-class | 慢slow | C 级C-class | C 级C-class |
完整语法书、编译器设计、示例库,全部开源。Full grammar, compiler design and example corpus — all open source.