Integrating WebView with Nature Programming Language

https://news.ycombinator.com/rss Hits: 1
Summary

A developer attempted to integrate WebView into the Nature programming language (project repository: https://github.com/wzzc-dev/nature-webview) using an integration approach similar to Rust's Tauri. After successful packaging, the result is a compact, lightweight executable desktop application. Here's a simple hello world example: import webview as w import webview.{webview_t} import libc.{cstr, to_cfn} import co.{sleep} import co import runtime fn interval_callback() { co.yield() // Yield coroutine every 10ms to allow GC to run } fn other() { for true { println('other co') sleep(1000) } } fn main() { println("Hello, Nature Webview!") @async(other(), co.SAME) var window = w.create(1, null) w.set_title(window, "Hello World".to_cstr()) w.bind(window, "interval_callback".to_cstr(), to_cfn(interval_callback as anyptr), 0) var html = ` <html> <body> <script>setInterval(() => {window.interval_callback();}, 10);</script> <h1>Hello, Nature!</h1> </body> </html>` w.set_html(window, html.to_cstr()) w.run(window) // blocking coroutine! w.destroy(window) } Nature is a programming language based on a global coroutine model, and its compatibility with WebView was not ideal initially. The solution failed to run entirely at first. The author of nature-webview reached out to me, and I recognized this as a highly meaningful effort that represents an important step in enabling GUI support for Nature. I therefore set out to identify and resolve the issues preventing the solution from running. After a weekend of work, the major issues were resolved, and I couldn't wait to share this achievement! WebView Must Run on the t0 System Stack + System Thread On macOS, the program started successfully after compilation, but crashed when attempting to callback from JavaScript to Nature. The crash stack trace was extremely deep and difficult to trace. Even when building WebView in Debug mode, a complete stack trace could not be obtained. I eventually discovered that this was because WebView dynam...

First seen: 2026-01-26 05:56

Last seen: 2026-01-26 05:56