Perry
zh-Hans
v0.5.306 — 分代 GC + 惰性 JSON 磁带为默认,在大多数基准上比 Node 与 Bun 更快

一套代码。所有平台。
原生性能。

Perry 将 TypeScript 编译为 macOS、iPadOS、iOS、Android、Linux、Windows、watchOS、tvOS、WebAssembly 和 Web 上的原生 GUI 和 CLI 应用。无需运行时。无需 Electron。只有原生二进制文件。

terminal
$ perry compile main.ts
正在编译 main.ts...
✓ 已编译可执行文件:main(2.3 MB)

$ ./main
Hello, World!
10
目标平台
25+
原生 UI 组件
<50 ms
启动时间
App Store
就绪

为什么选择 Perry

将 TypeScript 编译为原生应用所需的一切

noRuntime
fastCompilation
smallBinaries
deterministicBuilds
stdLib
v8Runtime
widgets
plugins
threading
i18n

看看人们在构建什么

真正的原生应用,从 TypeScript 编译。没有 Electron,没有 Web View — 每个平台上都是原生 UI。

Mango

Mango

原生 MongoDB GUI — 完全用 TypeScript 构建

macOSLinuxWindows
Mango — document editor
Mango — query explorer
Hone

Hone

原生 AI 代码编辑器 — TypeScript 编译为原生二进制

macOSiOSWeb
Hone — native AI code editor

每个平台上原生运行

Perry 将您的 TypeScript 编译为原生 UI 框架、WebAssembly 和 JavaScript——不是 Web 视图,不是 Electron。每个平台上都是真正的原生组件,外加 Web。

🍎
macOS
稳定
📱
iOS
稳定
📲
iPadOS
稳定
watchOS
稳定
📺
tvOS
稳定
🤖
Android
稳定
🐧
Linux
稳定
🪟
Windows
稳定
🌐
Wasm
稳定
💻
Web
稳定

从代码到 App Store

Perry 不仅编译您的应用——还将其送到用户手中。

perry compile编译并签名
perry publish打包并提交
商店和下载App Store、Play Store、直接分发
perry verify测试每个平台

构建并签名

一条命令完成跨平台构建。macOS、iOS、Android 和 Windows 的代码签名自动处理。无需与 Xcode 配置文件或 Android 密钥库搏斗。

分发

推送到 App Store、Play Store,或提供直接下载。Perry Publish 处理打包、公证和提交。

验证

由 Geisterhand 驱动。在全部 6 个平台上进行自动化 UI 测试。在用户告诉您之前,确保您的应用在所有地方都能正常工作。

开源项目免费。 团队方案 → /publish

框架对比

唯一满足所有条件的框架

TypeScript 编译为原生代码。真正的平台组件。零运行时开销。

框架语言原生代码原生组件运行时开销
PerryTypeScript✓ 原生编译✓ 真正的平台组件✓ 零运行时开销
React NativeJS / TSJS bridge部分JS engine + bridge
FlutterDartAOT无共享 UIDart VM
ElectronJS / TSChromium runtimeHTML mimicsChromium + Node

编写 TypeScript,交付原生应用

使用熟悉的 TypeScript 语法和 API。Perry 处理剩下的一切。

hello.ts
// hello.ts
const greeting = "Hello, World!";
console.log(greeting);

// Compiles to ~2MB native executable
// No runtime needed!
$ perry build hello.ts
原生二进制文件

性能对比

原生编译带来无与伦比的效率

二进制文件大小
1.8 MB
Bun 96 MB · Node 110 MB
启动时间
<50 ms
Bun ~200 ms · Node ~800 ms
运行时依赖
Bun + Node need runtimes
内存开销
极少
Bun ~80 MB · Node ~120 MB

开始使用

安装 Perry,开始将 TypeScript 编译为原生可执行文件

Homebrew(macOS)

brew install perry-ts/perry
需要 Homebrew。支持 macOS arm64 和 x86_64。

APT(Debian/Ubuntu)

apt-get install perry
支持 x86_64 和 arm64 Linux。

Windows(winget)

scoop install perry-ts/perry
需要 Windows 包管理器。支持 Windows x86_64 和 arm64。

功能支持

全面覆盖 TypeScript 和 Node.js API

Core Language

  • Numbers64-bit floating point (f64)
  • StringsUTF-8, all common methods
  • Booleanstrue/false, logical operators
  • ArraysTyped and mixed-type arrays
  • ObjectsObject literals and field access
  • BigInt256-bit integer support
  • EnumsNumeric and string enums

Functions

  • Function DeclarationNamed functions
  • Arrow Functions() => {} syntax
  • Default ParametersParameters with defaults
  • Rest Parameters...args syntax
  • ClosuresIncluding mutable captures
  • Higher-OrderFunctions as arguments/returns
  • Async/AwaitAsync function support

Classes

  • Class DeclarationBasic class syntax
  • ConstructorsWith parameters
  • Private Fields (#)ES2022 #privateField syntax
  • Static Methods/FieldsClass-level members
  • Getters/Settersget/set accessors
  • Inheritanceextends keyword
  • Super Callssuper() constructor calls

Type System

  • Type AnnotationsExplicit type declarations
  • Type InferenceAutomatic type detection
  • GenericsMonomorphization (like Rust)
  • InterfacesInterface declarations
  • Union Typesstring | number support
  • Type Guardstypeof operator
  • Type Aliasestype X = ... declarations

Standard Library

  • fsreadFileSync, writeFileSync, existsSync, etc.
  • pathjoin, dirname, basename, extname, resolve
  • cryptorandomBytes, randomUUID, sha256, md5
  • osplatform, arch, hostname, memory info
  • Bufferfrom, alloc, toString, slice, copy
  • child_processexecSync, spawnSync
  • JSON/Math/DateFull implementations
完全支持
部分

30+ 原生 npm 包

热门 npm 包以原生 Rust 重新实现。无需 npm install,无需 node_modules,只有快速的原生代码。

数据库

mysql2pgmongodbbetter-sqlite3ioredis

安全

bcryptargon2jsonwebtokencrypto

HTTP

httphttpsaxiosnode-fetchwsnodemailer

数据处理

cheeriosharpzliblodash

日期和时间

dayjsmomentdate-fnsnode-cron

工具

uuidnanoidslugifyvalidatordotenvrate-limiter-flexible
只需 import 即可使用——Perry 自动使用原生实现

工作原理

从 TypeScript 源码到原生可执行文件,仅需数秒

TypeScript.ts 文件
SWC
解析器快速解析
HIR
转换Monomorphization
LLVM
代码生成机器码
可执行文件2-5 MB 二进制文件

想了解编译器内部是如何工作的吗? 编译器内部原理