[HN Gopher] Trealla Prolog embedded in Go using WASM
       ___________________________________________________________________
        
       Trealla Prolog embedded in Go using WASM
        
       Author : triska
       Score  : 66 points
       Date   : 2022-08-07 14:59 UTC (8 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | grose wrote:
       | 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 wrote:
         | >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 wrote:
           | Using 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.
        
       | triska wrote:
       | Trealla Prolog is one of the most interesting new Prolog systems:
       | In particular, it is the first Prolog system that uses mmap(2) to
       | map files to memory for _direct_ processing of file contents with
       | Prolog 's built-in grammar mechanism, Definite Clause Grammars
       | (DCGs).
       | 
       | 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!
        
       | ggleason wrote:
       | Prolog is still the best query language out there. If it had as
       | much attention as other languages like python or javascript, we'd
       | have some real space-age programming systems.
        
       ___________________________________________________________________
       (page generated 2022-08-07 23:01 UTC)