TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Zaplib – Speed up your webapp with Rust+Wasm

175 pointsby stevekrouseabout 3 years ago

12 comments

janpaul123about 3 years ago
Hey HN, one of the creators here! I made it at Cruise because it was super painful to develop <a href="https:&#x2F;&#x2F;webviz.io" rel="nofollow">https:&#x2F;&#x2F;webviz.io</a> with manual memory management (lots of ArrayBuffers), WebWorkers, etc. I thought that there must be a better way.<p>Very curious to hear stories from other folks building intensive stuff in the browser. How are you dealing with performance issues in Javascript? Have you tried using Rust or C++ with WebAssembly for parts of your apps? How did you make 2d&#x2F;3d rendering faster? Would you want to use something like Zaplib?<p>(You may have seen my blog yesterday about the subtleties about Wasm vs JS&#x2F;TS: <a href="https:&#x2F;&#x2F;zaplib.com&#x2F;docs&#x2F;blog_ts++.html" rel="nofollow">https:&#x2F;&#x2F;zaplib.com&#x2F;docs&#x2F;blog_ts++.html</a>)
评论 #30963801 未加载
评论 #30965722 未加载
FullyFunctionalabout 3 years ago
Hot damn I nearly got a seissure from watching the demo page. I&#x27;m sure flickering mess I see with Firefox 98.0.2 wasn&#x27;t what they intended!<p>I can&#x27;t really say much else about it, but it looks interesting.<p>ADD: not complaining about the down votes, but I wasn&#x27;t kidding. I think it&#x27;s malfunctioning in my browser in a literally dangerous way. I would record a video of it if it wasn&#x27;t so annoying to upload. I&#x27;m guess nobody else sees this?
评论 #30965575 未加载
评论 #30965994 未加载
chaosprintabout 3 years ago
Great work. Put it on my favourite list now. Do you have any tips for debugging? I use the same combo Rust-WASM for my Glicol music programming language:<p><a href="https:&#x2F;&#x2F;glicol.org" rel="nofollow">https:&#x2F;&#x2F;glicol.org</a><p>The audio runs in AudioWorklet thread while I guess for Zaplib it runs in Workers, right? Did you use SAB in Zaplib?<p>For me, one use case is to use Zaplib for visualising the audio. The built-in canvas and 2d drawing is really slow. Yet one concern is for the support on Safari. It really has a slow support for SAB. I have to switch to postMessage on Safari as a compromise.
评论 #30961304 未加载
评论 #30961403 未加载
ggerganovabout 3 years ago
I&#x27;ve been using a similar stack (C++ and WASM) to build some simple applications and I enjoy it very much. For the UI components, text rendering and layout I use Dear ImGui [0] as I am very familiar with it and it allows me to implement GUIs very fast. The biggest convenience is that you can run the same code both as a native application and as a web app. The biggest drawback is you usually get 100% CPU usage when there is an active animation in the WebGL canvas because you need to redraw everything (similar to the OP&#x27;s example).<p>If you are interested, checkout my Github template repo [1] - it contains a few examples:<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;ocornut&#x2F;imgui" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ocornut&#x2F;imgui</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;ggerganov&#x2F;ggweb" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ggerganov&#x2F;ggweb</a>
评论 #30965039 未加载
评论 #30961182 未加载
评论 #30961109 未加载
rklaehnabout 3 years ago
This looks awesome. I have been playing with WASM and rust, trying to get rusqlite to work with persistence, among other things.<p>I notice that you also came to the conclusion that having all io async is not the way to go for rust.<p>How do you wrap the async js io apis so they can be used in sync rust? I have seen different approaches for this: 1. an additional service worker &#x2F; thread and atomics. 2. rewrite the entire WASM in some sort of continuation passing style.
评论 #30969624 未加载
wngrabout 3 years ago
Nice project, although pretty opinionated. But I guess you have to do that when targeting the crazy browser environment with all its weird quirks (at least for non-web devs)..<p>Somewhat related is a library I&#x27;ve been working on to generate an ffi between Rust and js code: <a href="https:&#x2F;&#x2F;github.com&#x2F;cloudpeers&#x2F;ffi-gen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cloudpeers&#x2F;ffi-gen</a><p>Also I really like your <i>universal_thread</i> abstraction, hiding the whole web worker mess. I did a similar thing here: <a href="https:&#x2F;&#x2F;github.com&#x2F;wngr&#x2F;wasm-futures-executor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wngr&#x2F;wasm-futures-executor</a>
prianshabout 3 years ago
This is really cool but I can’t say I’m a fan of Zapium given it would move to a commercial license in the future. If you have to ship CEF anyhow, what is the performance advantage to licensing and using Zapium over just compiling WASM and shipping binaries with Electron? FWIW — this is how Java, .NET, etc packaging is done for interop with Electron.<p>I can understand from an ease of use perspective to have the bridge in between but it wouldn’t be worth subjecting a codebase to commercial licensing IMO. It’s not a whole lot more work to use process calls instead there so it seems an odd choice to commercialize that aspect in particular.
评论 #30962893 未加载
评论 #30962703 未加载
areisabout 3 years ago
Super cool! I&#x27;m sure this is highly situational, but roughly how much faster can Rust -&gt; WASM be than vanilla JS? 2x, 10x, 100x?
评论 #30961372 未加载
andrew_shayabout 3 years ago
Great to see more work in the Rust+Wasm space. Interested in trying this out at some point.
cglongabout 3 years ago
Just tried opening this on my cheap Android phone; really appreciate that the whole page stayed usable! There was some noticable lag though, which I don&#x27;t see on advanced Three.js apps. So some further performance tuning might be needed :)
评论 #30961389 未加载
nrabulinskiabout 3 years ago
None of the demos work in Safari on iOS.<p>iPhone XS on iOS 15.0.2
评论 #30961035 未加载
jxjshawabout 3 years ago
this is dope!!