r/C_Programming • u/8d8n4mbo28026ulk • Jul 05 '26
Library-fying AWK with WASM
https://napcakes.nekoweb.org/posts/libawk-wasm/
9
Upvotes
r/C_Programming • u/8d8n4mbo28026ulk • Jul 05 '26
View all comments
Show parent comment
1
u/8d8n4mbo28026ulk Jul 05 '26
Thanks for the kind words and... I'm on it!
Yeah, it isn't great in that regard. However, I forgive all of this just because how easy it was to build it and play with it. And it's also a stand-alone project. It would be pretty painful to try this with, e.g. GNU awk, which is a ~800K binary -- you can imagine how that would go with WASM, LOL! I suspect BusyBox' wouldn't be easy either...
Indeed, if it was written differently, the crazy WASM stuff wouldn't be needed in the first place. I knew this going in, because I wanted to test whether WASM can be used in such a way.
This was me just toying around; I don't think I'll ever need to embed AWK in one of my programs. Wikipedia lists some projects with that use in mind though, so there exist options out there.
And shamelessly, I might say, haha! I wrote libawk with
dedup-wawkin my mind. I knew that if I could make that work with some sane API, everything else would be a case of "just do it".nawkreads fromstdinby default, soopen()and friends weren't necessary for the test application.Good point. If I was serious about this, I'd reimplement the whole memory subsystem myself and most likely use an arena that would be rollbacked whenever necessary.
wasm2clet's you do it -- it was just easier to use the default implementation.Ah, right, here's me mixing up terms in the very paragraph I'm saying I'll mixup terms! I only skimmed through WASM's documentation, just to understand a little how it all works. It never got in my way, so I didn't spend a lot of time on it. WASI, though, is exactly what you said: a complete disaster (I'd be even more harsh).