Doo:一个基于 Rust 和 LLVM 构建的简单、快速编程语言

1作者: nynrathod7 个月前
嗨,各位 HN 用户! [https://github.com/nynrathod/doolang](https://github.com/nynrathod/doolang) 我是 Nayan,很高兴与大家分享 Doo,这是我从一个项目发展而来的副业,它是一种编写起来极其简单的语言,但性能却能媲美 Rust。 它的特点包括:简洁的语法(灵感来源于 Rust,但减少了样板代码),通过引用计数实现自动内存管理(无 GC 停顿),丰富的类型,并且通过 LLVM/clang 生成独立的本地二进制文件。 为什么选择 Doo? 编程应该充满乐趣,而不是充满斗争。不再需要为了写一个“hello world”而与生命周期或宏作斗争,但仍然保证安全和速度。 快速浏览 (hello.doo): ``` fn main() { let msg = "Hey HN!"; print(msg); } ``` * 静态类型系统:编译时类型检查,带类型推断 * 自动内存管理:数据类型使用引用计数 * 丰富的数据类型:整数、字符串、布尔值、数组、映射和元组 * 模块系统:通过分层导入系统组织代码 * 控制流:条件语句、for 循环和范围迭代 * 函数系统:一等函数,带有参数和返回类型注释 * 原生编译:使用 clang/lld 编译为独立的可执行文件 仓库:[https://github.com/nynrathod/doolang](https://github.com/nynrathod/doolang) (欢迎点赞/提交 Pull Request!) 你们觉得怎么样? 太像 Rust 了吗? 缺少什么杀手级功能吗?
查看原文
Hey HN!<p>https:&#x2F;&#x2F;github.com&#x2F;nynrathod&#x2F;doolang<p>I&#x27;m Nayan, and I&#x27;m stoked to share Doo, my project turned side hustle for a lang that&#x27;s dead simple to write but punches like Rust. Think clean syntax (inspired by Rust but less boilerplate), auto memory mgmt via ref counting (no GC pauses), rich types, and it spits out standalone native bins via LLVM&#x2F;clang.<p>Why Doo? Coding should feel fun, not fighty. No more wrestling with lifetimes or macros just to get a &quot;hello world&quot; but still safe and speedy.<p>Quick tour (hello.doo):<p>fn main() { let msg = &quot;Hey HN!&quot;; print(msg); }<p>Static Type System: Compile-time type checking with type inference Automatic Memory Management: Reference counting for data types Rich Data Types: Integers, strings, booleans, arrays, maps, and tuples Module System: Organize code with a hierarchical import system Control Flow: Conditional statements, for loops, and range iteration Function System: First-class functions with parameter and return type annotations Native Compilation: Compiles to standalone executables using clang&#x2F;lld<p>Repo: https:&#x2F;&#x2F;github.com&#x2F;nynrathod&#x2F;doolang (stars&#x2F;pulls welcome!)<p>What do you think? Too Rust-y? Missing a killer feature?