Wren: 一种优雅的小型脚本语言
Wren: A classy little scripting language

原始链接: https://wren.io/

Wren 是一种新的、小型、快速且并发的脚本语言,设计用于嵌入应用程序。它受到 Smalltalk、Lua 和 Erlang 的启发,提供现代语法和基于类的对象模型——这是许多其他脚本语言中经常缺乏的特性。 尽管代码量很小(不到 4,000 行!),Wren 仍然优先考虑可读性,具有清晰的注释。它通过快速编译器和高效的字节码实现速度。Wren 设计的核心是轻量级协程,通过协程实现轻松的并发。 Wren 没有外部依赖,标准库极小,并且具有简单的 C API,可使用 C99、C++98 及更高版本进行编译。它甚至可以在浏览器中运行,使其易于访问和实验。

## Wren:一种优雅的脚本语言 - 摘要 Wren 是一种新兴的脚本语言,正受到关注,其创建者同时也是著名书籍《Crafting Interpreters》的作者。讨论主要集中在 Wren 的设计选择上,特别是其受 Smalltalk 影响的面向对象方法,以及通过诸如复制继承等技术带来的性能优势。 用户正在探索 Wren 作为 Lua 和 JavaScript 等语言的替代品,用于嵌入应用程序,特别提到了它在游戏引擎(如 Luxe)和 WASM 自定义运行时中的潜力。虽然 Wren 因其优雅和易于理解而受到赞扬,但对其类实现以及缺乏传统的元类继承存在一些争论。 对话还涉及 Squirrel 和 LuaJIT 等相关语言,以及学习语言实现的资源。总而言之,Wren 被定位为一种有希望的选择,适用于寻求轻量级、高性能且经过深思熟虑的脚本语言的开发者。
相关文章

原文

Wren is a small, fast, class-based concurrent scripting language


Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax.

System.print("Hello, world!")

class Wren {
  flyTo(city) {
    System.print("Flying to %(city)")
  }
}

var adjectives = Fiber.new {
  ["small", "clean", "fast"].each {|word| Fiber.yield(word) }
}

while (!adjectives.isDone) System.print(adjectives.call())
  • Wren is small. The VM implementation is under 4,000 semicolons. You can skim the whole thing in an afternoon. It’s small, but not dense. It is readable and lovingly-commented.

  • Wren is fast. A fast single-pass compiler to tight bytecode, and a compact object representation help Wren compete with other dynamic languages.

  • Wren is class-based. There are lots of scripting languages out there, but many have unusual or non-existent object models. Wren places classes front and center.

  • Wren is concurrent. Lightweight fibers are core to the execution model and let you organize your program into a flock of communicating coroutines.

  • Wren is a scripting language. Wren is intended for embedding in applications. It has no dependencies, a small standard library, and an easy-to-use C API. It compiles cleanly as C99, C++98 or anything later.


You can try it in your browser!
If you like the sound of this, let’s get started.
Excited? You’re also welcome to get involved!

联系我们 contact @ memedata.com