Tauri v2 vs Electron After 6 Months of Real Development — My Honest Take

Tauri v2 vs Electron After 6 Months of Real Development — My Honest Take

Tauri v2 对比 Electron:六个月真实开发后的诚恳心得

All tests run on an 8-year-old MacBook Air. I’ve shipped multiple Mac apps with Tauri v2. I evaluated Electron seriously before choosing Tauri. Here’s what 6 months of actual development taught me — not benchmarks, actual experience. 所有测试均在一台 8 年前的 MacBook Air 上运行。我已使用 Tauri v2 发布了多款 Mac 应用。在选择 Tauri 之前,我曾认真评估过 Electron。以下是我 6 个月真实开发后的心得——这不是基准测试,而是实战经验。

Bundle size: Tauri wins, obviously Electron bundles Chromium. Your app is 150MB before you write a line of code. Tauri uses the system WebView (WKWebView on macOS). My largest app is under 10MB as a DMG. For a paid app distributed outside the App Store, this matters. A 150MB download for a PDF tool is a hard sell. 安装包大小:Tauri 完胜。显而易见,Electron 捆绑了 Chromium,这意味着你在写下一行代码之前,应用就已经有 150MB 了。Tauri 使用系统自带的 WebView(macOS 上为 WKWebView)。我最大的应用打包成 DMG 后不到 10MB。对于在 App Store 之外分发的付费应用来说,这一点至关重要。让用户下载一个 150MB 的 PDF 工具是非常困难的。

The Rust learning curve is real. Electron lets you write everything in JavaScript. Tauri requires Rust for the backend. If you know Rust: Tauri is a joy. The type system catches errors before they reach users. The performance headroom is enormous. If you don’t know Rust: budget 2-3 months of frustration before you’re productive. The borrow checker will fight you on everything involving shared state between async tasks. I knew some Rust going in. It still took longer than I expected. Rust 的学习曲线确实存在。Electron 允许你用 JavaScript 完成一切,而 Tauri 的后端需要 Rust。如果你懂 Rust,Tauri 用起来非常愉悦,类型系统能在错误触达用户前将其捕获,且性能上限极高。如果你不懂 Rust,请预留 2-3 个月的挫败期才能进入高效开发状态。在处理异步任务间的共享状态时,借用检查器(Borrow Checker)会让你处处碰壁。我入门前已经懂一些 Rust,但开发耗时依然超出了我的预期。

Where Tauri v2 surprised me (positively): The capabilities/permissions system is well thought out. Granular control over exactly what each window can access. The plugin ecosystem is growing fast. tauri-plugin-fs, tauri-plugin-shell, tauri-plugin-notification — most of what you need exists. IPC between frontend and Rust backend via invoke() is clean and type-safe with the right setup. Tauri v2 令我惊喜的地方(正面):其能力/权限系统设计得非常周全,可以精确控制每个窗口的访问权限。插件生态发展迅速,tauri-plugin-fs、tauri-plugin-shell、tauri-plugin-notification 等,你所需的大部分功能都有现成的插件。通过 invoke() 在前端和 Rust 后端之间进行 IPC 通信,在正确配置下既简洁又类型安全。

Where Tauri v2 frustrated me: macOS-specific native API access is manual. Calling PDFKit or Vision Framework requires a Swift/ObjC sidecar binary. Tauri doesn’t abstract this — you build and manage the bridge yourself. It works, but it’s not documented well. Hot reload is flaky. cargo tauri dev hot reloads the frontend fine. Rust changes require a full recompile. For a complex app this is 30-60 seconds per backend change. Electron’s dev experience is faster. Error messages from the JS side are opaque. When a Tauri command fails, the error that surfaces in the frontend is often just “command failed.” You need explicit error serialization on the Rust side to get useful messages. Tauri v2 令我沮丧的地方:访问 macOS 特有的原生 API 需要手动操作。调用 PDFKit 或 Vision Framework 需要一个 Swift/ObjC 的辅助二进制文件。Tauri 没有对此进行抽象,你需要自己构建和管理这座桥梁,虽然可行,但文档并不完善。热重载不稳定:cargo tauri dev 对前端的热重载效果很好,但 Rust 代码的变更需要完整重新编译。对于复杂应用,每次后端变更需要等待 30-60 秒,Electron 的开发体验要快得多。JS 端的错误信息不透明:当 Tauri 命令失败时,前端收到的错误通常只是“command failed”。你必须在 Rust 端进行显式的错误序列化,才能获得有用的错误信息。

The verdict: Tauri v2 for apps where bundle size, performance, and Rust access matter. Electron for teams that move fast in JavaScript and don’t need the performance headroom. Not a universal answer. Depends on your constraints. 结论:如果你看重安装包大小、性能以及 Rust 的访问能力,请选择 Tauri v2。如果你是追求 JavaScript 开发速度且不需要极致性能的团队,请选择 Electron。没有万能的答案,取决于你的具体需求。