Trealla Prolog embedded in Go using WASM
github.com
github.com
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.
Could you please expand this with more details?
You can see the relevant code here: 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.
This is possible in Trealla due to its compact internal representation of lists of characters by using UTF-8 encoding internally, a representation pioneered by Scryer Prolog.
Thank you a lot gurego for all your work on this WASM embedding!
I get the feeling there's more to Prolog than I was able to unlock - can you recommend any reference materials for beginners?
In theory (!), the binaries produced should be a bunch smaller than the standard Go compiler ones... though I haven't yet tried myself. :)