4 ms·
Oh hey, this is mine. Thanks to triska for submitting it, and for his Power of Prolog lecture videos. I got started learning Prolog with them this year. This p
by grose 4y ago
Oh hey, this is mine. Thanks to triska for submitting it, and for his Power of Prolog lecture videos. I got started learning Prolog with them this year.
This package uses the novel (at least, novel to me) method of embedding a small C program (Trealla Prolog) through WASM/WASI and exposing it as a regular Go library. My hopes are that it can give us easier cross-platform compatibility going forward, and has some memory isolation/security benefits too. It's kind of like running a "serverless" worker architecture locally, which is kinda cool IMO.
This package is still in its early phases but I highly suggest that everyone checks out Prolog if it sounds interesting to them. It is a very powerful and very cool language that can change the way you approach solving problems. I'm currently working towards getting Prolog easier to embed and use in different languages, and I think Trealla is a great asset towards this.
- brokenkebab2 4y ago>This package uses the novel (at least, novel to me) method of embedding a small C program (Trealla Prolog) through WASM/WASI and exposing it as a regular Go library Could you please expand this with more details?
- speps 4y agoUsing a WASI runtime in Go you can run any code compiled to WASM. That also means you can wrap a C (or other) library compiled to WASM into a Go library.
- grose 4y agoI plan on writing a blog post soon to explain it better. The quick summary is that it uses WASI to execute a C program not entirely unlike oldschool CGI, but now it's inside of a WebAssembly runtime instead of an OS process. It uses command line arguments to send the query and standard output to grab the results. This may become fancier in the future. You can see the relevant code here: https://github.com/guregu/trealla-go/blob/333645147df083dd26f72518cc9903b1ce9c1721/trealla.go#L119 https://github.com/guregu/trealla-go/blob/333645147df083dd26... that builds up the command line arguments for tpl (the Trealla binary, shoved into the repo as tpl.wasm). The rest of the package is mostly shuffling data around.