Revo Programming language

Revo Programming Language

Revo, the programming language Docs | GitHub Revo is a dynamic language made for the joy of programming. Get it, try it in your browser, join the Discord, or read the introduction.

Revo,编程语言 文档 | GitHub Revo 是一门为编程乐趣而生的动态语言。你可以获取它、在浏览器中尝试、加入 Discord 社区或阅读入门介绍。


Features / 特性

Pipes: Clean data flow without nesting; things flow from top to bottom. 管道: 清晰的数据流,无需嵌套;数据从上到下流动。

Run errors-as-values: Nil and booleans are replaced by atoms. You can’t use a value without handling an error. All crashes are explicit (WIP). Aided massively by pattern matching, ?, orelse, and :unwrap(). 错误即值: Nil 和布尔值被原子(atoms)取代。如果不处理错误,你就无法使用该值。所有崩溃都是显式的(开发中)。得益于模式匹配、?orelse:unwrap(),处理过程非常顺畅。

Run everything is an expression: No statements; everything (really) always returns a value… but the code still looks procedural. 一切皆表达式: 没有语句;所有东西(真的)总是返回一个值……但代码看起来仍然是过程式的。

Run comp: Execute any (really) expression at compile time. Any script can be compiled into bytecode and get any value baked in. The compile-time VM does not differ from the runtime one. 编译期执行: 在编译时执行任何(真的)表达式。任何脚本都可以编译成字节码并将任何值预先计算进去。编译期虚拟机与运行时虚拟机没有区别。

Run procedural macros: Along with an AST-substituting macro system, this lets you just get an iterator over the raw AST tokens, run any code to transform them, then return back a table of the new AST. 过程宏: 配合 AST 替换宏系统,你可以获取原始 AST 标记的迭代器,运行任何代码进行转换,然后返回一个新的 AST 表。

Run pattern matching: Destructure and branch in place. You will be using atoms and tuples; they are beautiful solutions to their problems. 模式匹配: 原地解构和分支。你将使用原子和元组;它们是解决问题的优雅方案。

Run fibers: I made all your blocking code become non-blocking by just adding a spawn before it. 纤程(Fibers): 我让所有的阻塞代码只需在前面加上 spawn 即可变为非阻塞。

Run tables: Represent everything; used for module exports, arrays, and maps. 表(Tables): 代表一切;用于模块导出、数组和映射。

Run convenient typing: The type system is optional, but very well-integrated. Untyped code works just fine, but typed code is faster and gets optimized better (and ensures code correctness at compile-time!). Most of your code is going to be inferred automatically. 便捷的类型系统: 类型系统是可选的,但集成度很高。无类型代码运行良好,但有类型代码更快且优化更好(并确保编译时的代码正确性!)。你大部分的代码都将被自动推断。

Run first-class tests: They’re just closures and they fail when you return an error. The ? postfix operator propagates errors, giving you a pretty simple experience. 一等公民测试: 它们只是闭包,当你返回错误时它们就会失败。? 后缀运算符会传播错误,为你提供非常简单的体验。


Installation / 安装

Get: The latest release is hosted at GitHub releases. However, this project is rapidly changing. I recommend you build from source instead. If a binary release is older than a week, it’s likely that it has some critical bugs that are fixed already. 获取: 最新版本托管在 GitHub Releases。然而,该项目变化迅速,我建议你从源码构建。如果二进制版本超过一周,它很可能存在已经修复的关键 Bug。

Install from source: You need Zig 0.16.0 to build Revo. I also recommend the anyzig version manager. 从源码安装: 你需要 Zig 0.16.0 来构建 Revo。我也推荐使用 anyzig 版本管理器。

Linux/BSD/Mac/etc:

git clone https://github.com/if-not-nil/revo --recursive && cd revo
git submodule update --init --recursive
zig build --fetch
zig build -Doptimize=ReleaseSafe
cp ./zig-out/bin/revo ~/.local/bin/revo
revo

Windows: [!NOTE] Some features are unavailable on Windows. I recommend using WSL with the steps above. [!NOTE] 部分功能在 Windows 上不可用。我建议使用 WSL 并按照上述步骤操作。


Tools / 工具

LSP: Diagnostics, highlighting, etc., in your editor! Bundled by default with your Revo. LSP: 编辑器中的诊断、高亮等功能!随 Revo 默认捆绑。

Docs: Output docs in plaintext/html. 文档: 输出纯文本/HTML 格式的文档。

revo doc <file or directory>
revo doc --html <file or directory>

Editors: VS Code, Neovim, Helix, Emacs. 编辑器: 支持 VS Code、Neovim、Helix 和 Emacs。


Credits / 致谢

  • isocline by daanx - MIT
  • lsp-kit by the zigtools team - MIT