# Embedding Wren in Hare

DevFeed: [Embedding Wren in Hare](<https://devfeed.tech/articles/embedding-wren-in-hare-20796.md>)

Original publisher: [Read original article](<https://drewdevault.com/blog/Hare-and-Wren/>)

Author: August

Published: 2025-08-20T00:00:00Z

Content type: article

Language: en

Sources: [Drew DeVault](<https://devfeed.tech/sources/drew-devault.md>)

Topics: [Scripting](<https://devfeed.tech/topics/scripting.md>), [API](<https://devfeed.tech/topics/api.md>), [Library](<https://devfeed.tech/topics/library.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [C](<https://devfeed.tech/topics/c.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [cli](<https://devfeed.tech/tags/cli.md>), [library](<https://devfeed.tech/tags/library.md>), [scripting](<https://devfeed.tech/tags/scripting.md>)

## AI overview

The article introduces hare-wren, an interface for embedding the Wren scripting language in Hare programs. It describes its Hare-oriented wrapper around the Wren C API, bidirectional calls between Hare and Wren, an optional asynchronous runtime and standard library, file and process-environment features, third-party module loading, and command-line access without a REPL.

## Source excerpt

I've been on the lookout for a scripting language which can be neatly embedded into Hare programs. Perhaps the obvious candidate is Lua - but I'm not particularly enthusiastic about it. When I was evaluating the landscape of tools which are "like Lua, but not Lua", I found an interesting contender: Wren. I found that Wren punches far above its weight for such a simple language. It's object oriented, which, you know, take it or leave it depending on your use-case, but it's very straightforwardly interesting for what it is. I found a few things to complain about, of course - its scope rules are silly, the C API has some odd limitations here and there, and in my opinion the "standard library" provided by wren CLI is poorly designed. But, surprisingly, my list of complaints more or less ends there, and I was excited to build a nice interface to it from Hare. The result is hare-wren. Check it out! The basic Wren C API is relatively straightforwardly exposed to Hare via the wren module, though I elected to mold it into a more idiomatic Hare interface rather than expose the C API directly to Hare. You can use it something like this: use wren; export fn main() void = { const vm = wren::new(wren::stdio_config); defer wren::destroy(vm); wren::interpret(vm, "main", ` System.print("Hello world!") `)!; }; $ hare run -lc main.ha Hello world! Calling Hare from Wren and vice-versa is also possible with hare-wren, of course. Here's another example: use fmt; use wren; export fn main() void = { let config = *wren::stdio_config; config.bind_foreign_method = &bind_foreign_method; const vm = wren::new(&config); defer wren::destroy(vm); wren::interpret(vm, "main", ` class Example { foreign static greet(user) } System.print(Example.greet("Harriet")) `)!; }; fn bind_foreign_method( vm: *wren::vm, module: str, class_name: str, is_static: bool, signature: str, ) nullable *wren::foreign_method_fn = { const is_valid = class_name == "Example" && signature == "greet(_)" && is_static; if (!is_vali