HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
trealla-prolog
go
Go2022–2024
trealla-prolog / go

go

Trealla Prolog embedded in Go using WASM

2Distinct people
8Mentions
0Explicit recommenders
84GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Trealla Prolog embedded in Go using WASM

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month8 dated mentions

Observed mentions: 2022-08-07 14:59:30 UTC to 2024-07-18 14:39:55 UTC.

01232022-08-01 00:00:00 UTC to 2022-09-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 commentsAug 20222022-09-01 00:00:00 UTC to 2022-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-10-01 00:00:00 UTC to 2022-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-11-01 00:00:00 UTC to 2022-12-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2022-12-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2023-02-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-02-01 00:00:00 UTC to 2023-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-03-01 00:00:00 UTC to 2023-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-04-01 00:00:00 UTC to 2023-05-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-05-01 00:00:00 UTC to 2023-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-06-01 00:00:00 UTC to 2023-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-07-01 00:00:00 UTC to 2023-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsJul 20232023-08-01 00:00:00 UTC to 2023-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-09-01 00:00:00 UTC to 2023-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-10-01 00:00:00 UTC to 2023-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-11-01 00:00:00 UTC to 2023-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-12-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2024-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-02-01 00:00:00 UTC to 2024-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-03-01 00:00:00 UTC to 2024-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-01 00:00:00 UTC to 2024-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-05-01 00:00:00 UTC to 2024-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-06-01 00:00:00 UTC to 2024-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-07-01 00:00:00 UTC to 2024-08-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJul 2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Aug 20222022-08-01 00:00:00 UTC2022-09-01 00:00:00 UTC312
Sep 20222022-09-01 00:00:00 UTC2022-10-01 00:00:00 UTC000
Oct 20222022-10-01 00:00:00 UTC2022-11-01 00:00:00 UTC000
Nov 20222022-11-01 00:00:00 UTC2022-12-01 00:00:00 UTC202
Dec 20222022-12-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
Jan 20232023-01-01 00:00:00 UTC2023-02-01 00:00:00 UTC101
Feb 20232023-02-01 00:00:00 UTC2023-03-01 00:00:00 UTC000
Mar 20232023-03-01 00:00:00 UTC2023-04-01 00:00:00 UTC000
Apr 20232023-04-01 00:00:00 UTC2023-05-01 00:00:00 UTC101
May 20232023-05-01 00:00:00 UTC2023-06-01 00:00:00 UTC000
Jun 20232023-06-01 00:00:00 UTC2023-07-01 00:00:00 UTC000
Jul 20232023-07-01 00:00:00 UTC2023-08-01 00:00:00 UTC000
Aug 20232023-08-01 00:00:00 UTC2023-09-01 00:00:00 UTC000
Sep 20232023-09-01 00:00:00 UTC2023-10-01 00:00:00 UTC000
Oct 20232023-10-01 00:00:00 UTC2023-11-01 00:00:00 UTC000
Nov 20232023-11-01 00:00:00 UTC2023-12-01 00:00:00 UTC000
Dec 20232023-12-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
Jan 20242024-01-01 00:00:00 UTC2024-02-01 00:00:00 UTC000
Feb 20242024-02-01 00:00:00 UTC2024-03-01 00:00:00 UTC000
Mar 20242024-03-01 00:00:00 UTC2024-04-01 00:00:00 UTC000
Apr 20242024-04-01 00:00:00 UTC2024-05-01 00:00:00 UTC000
May 20242024-05-01 00:00:00 UTC2024-06-01 00:00:00 UTC000
Jun 20242024-06-01 00:00:00 UTC2024-07-01 00:00:00 UTC000
Jul 20242024-07-01 00:00:00 UTC2024-08-01 00:00:00 UTC101

What Hacker News says

8 sources
It's great to hear new people are interested in the language! I was enlightened a couple years ago and fell in love. Currently I'm focusing on creating easy-to-use embeddings of Trealla Prolog using Wasm. You can find my TypeScript library here: https://github.com/guregu/trealla-js and Go library here: https://github.com/trealla-prolog/go. The goal is to make the libraries as painless as possible. Trealla is a portable and lightweight Prolog written in C that supports CLP(Z) and is broadly compatible with Scryer. It's quite fast! I'm currently using it for some expert system stuff at $work and as an internet forum embedded scripting language for $fun. Speaking of Scryer, they recently got their WebAssembly build working and I hope to contribute a JS library for them in the future as their API stabilizes. Scryer and Trealla are both aiming
Read the rest
for ISO compatibility, so it's my hope that we can foster an ecosystem for modern ISO Prolog and provide more embeddings in the future. It's super convenient to get logic programmer superpowers in your favorite language. Also check out Scryer's new website: https://www.scryer.pl/ For something on the silly side, check out https://php.energy. Prolog Home Page, it's web scale :-). It's proof that you can integrate Prolog with bleeding edge stuff like Spin (server-side wasm ecosystem).
In Ask HN: What's Prolog like in 2024?
I think that Prolog will rise again. If you have an hour to kill, check out this video introduction by Markus Triska about what makes Prolog unique: https://www.youtube.com/watch?v=8XUutFBbUrg Recently I have been working on getting Trealla Prolog to run in WebAssembly. Support is quite good now, with an easy-to-use JS library[1], Go library[2], and is now one of the best-supported languages for the Spin runtime[3]. I think it's particularly nice for validations, you can write some simple Prolog rules and run the same code on the client and the server now. I would like to explore this more with a dedicated library at some point. Built-in features like DCGs make parsing/generating all kinds of data trivial. I love it. I think the biggest barrier to Prolog adoption is that it has a really steep learning curve, and most people get burnt by h
Read the rest
alf-assed introductions in college that tick the 'talked about logic programming' box in the syllabus. You really have to think in a completely different way to write a good Prolog program. But, once you get the right mindset, it makes solving complex problems incredibly easy. I don't really buy the argument that Datalog is enough. Most Datalog implementations I've seen hack on a bunch of extensions to do things like list membership. It would be awesome to see some serious effort put into an efficient Prolog-based database. The closest thing I can think of is TerminusDB, which I've never used but I wish I could convince my company to try it out ;). My dream is to have some kind of magical serverless persistent Prolog interpreter in the cloud. That's where I hope to take this Wasm stuff at some point. Can you imagine how powerful it would be to use Prolog instead of GraphQL or whatever? Prolog is IMO the perfect language for querying things, with a 1:1 correspondence to how you write the data. It's like SQL without all the ugly bits (I like SQL too, of course). If this sounds cool to you, check out the paper/book on Web Prolog[4] which is a fascinating dive into what a Prolog-based networked query system could look like. [1]: http://github.com/guregu/trealla-js [2]: http://github.com/trealla-prolog/go [3]: https://github.com/guregu/trealla#spin-components [4]: https://github.com/Web-Prolog/swi-web-prolog/raw/master/book...
In Why did Prolog lose steam? (2010)
Hey, this is mine. Thanks for submitting it. I'll answer some questions. > Why? I ported Trealla Prolog to WASM (WASI) and I was looking for something useful to test it against. I found Spin, which can run WASM+CGI, and landed on this. Making this project exposed a number of bugs in my port that have now been fixed, so consumers of more useful projects[1][2] benefit as well. Also, PHP style templates are just fun! There's something valuable to just being able to shove a little bit of code inside some HTML and get it up on the internet. I started my webdev journey with PHP many many years ago, and it's nice to revisit it from a different perspective. I don't use the real (elephant) PHP anymore, but I've gained a newfound appreciation for how fun its quick & dirty development style is. I hope this project can serve as an example of how to u
Read the rest
se Prolog for fun things. It does showcase some of the cooler dynamic aspects of the language, and the PHP parsing code is like 10 lines of DCG. > Is it a joke? Yes and no. The name is certainly a joke. I was pondering what 'Prolog on Rails' might be and thought calling it PHP would be funny. This led to the PHP-style templates which were quick to implement and pretty powerful. Despite the humorous presentation, it does actually work. > Can you use Prolog for web services? Yes! For example, SWI has a mature HTTP package: https://www.swi-prolog.org/pldoc/doc_for?object=section(%27p.... It's used to power SWISH, an online Prolog code sharing thing: https://swish.swi-prolog.org/ > Next steps? I would like to support persistence somehow. I think it'd be really cool if you could use Prolog's dynamic database[3] as a persistent store. Spin has components for Postgres and Redis so it shouldn't be too hard to implement, but I lose the WASI compatibility if I do that... which means I can't use the binary from WAPM, etc. I would also like to experiment with running Trealla on Cloudflare Workers. I have another project, worker-prolog[4], which uses Tau Prolog (a Prolog written in Javascript) on Workers. On a somewhat related note, I've also been playing around with Cosmopolitan libc[5]. I got Trealla to compile to an APE executable but there's some issues with the embedded Prolog libraries getting garbled, so I need to improve my GDB skills and figure out what's going on there. Finally, I'd like to say thanks to Andrew Davison (@infradig on GitHub), the author of Trealla Prolog, for letting me add WASM support to his project and helping me with lots of things. For example, PHP led to Andrew implementing improvements for using DCGs to parse Prolog terms, which is now super fast[6]! [1]: https://github.com/guregu/trealla-js [2]: https://github.com/trealla-prolog/go [3]: https://www.swi-prolog.org/pldoc/man?predicate=assertz/1 [4]: https://github.com/guregu/worker-prolog [5]: https://justine.lol/cosmopolitan/ [6]: https://github.com/trealla-prolog/trealla/issues/53
In PHP: Prolog Home Page
Other resources for logic programming and Go: ichiban/prolog - ISO Prolog interpreter in pure Go, getting close to v1: https://github.com/ichiban/prolog trealla-prolog/go - ISO Prolog interpreter embedded via WASM: https://github.com/trealla-prolog/go guregu/pengine - library for interfacing with Pengines (SWI-Prolog's RPC protocol): https://github.com/guregu/pengine biscuit-auth/biscuit-go - Biscuits are a fancy auth token with a little Datalog engine: https://github.com/biscuit-auth/biscuit-go I'm a big fan of logic programming. We've been seeing a small resurgence of interest in it (for example Yarn using Prolog made some waves) and I have some optimism for its future.
In Mangle, a programming language for deductive database programming
Nice article! I think this is an exciting approach to cross-platform support. I took a similar approach for Trealla Prolog's Go library: https://github.com/trealla-prolog/go The biggest roadblock at the moment is that Go WASM libraries are not in a very good state, except wazero. My assumption is that wazero will be slower than the cranelift-optimized wasmtime, etc. but I have not seen any benchmarks anywhere. My impressions of the Go WASM libraries: wazero: great Go-friendly API, not sure about performance, works on all OS (what the author chose) wasmer: provides bare-minimum input and output for WASI, fast (it's what I chose for trealla-go). Doesn't work on Windows without significant pain, doesn't static compile the wasmer libraries so distribution is a pain. Seems essentially abandoned as its main contributor left the company. wasmti
Read the rest
me: basically impossible to get input and output in any reasonable way (unable to set stdin or read stdout; it can only inherit the FDs from the host), but might finally get buffers for I/O soon. wasmedge: haven't investigated this yet, but it seems like it solves many of the problems above, promising If anyone knows of a benchmark between these, I'd love to see it. I'm especially interested in wazero's execution speed. I think I'll try and run Trealla against it. edit: I should also mention that wazero avoids the cgo overhead which could be a significant optimization for small functions as in this article, even if the runtime is slower. My use case is a long lived interpreter which is quite different.
In The Carcinization of Go Programs
Trealla is one of the most interesting new Prolog systems: Notably, as in other new systems such as Scryer and Tau Prolog and ichiban/prolog, the default setting of the Prolog flag double_quotes is chars, and therefore lists of characters can be conveniently written as double-quoted strings in Prolog code. Second, as in Scryer Prolog, such lists are very compactly encoded internally, making Trealla suitable for analyzing and processing very large amounts of text conveniently and efficiently. In addition, file contents can be processed directly with Prolog's built-in grammar formalism, Definite Clause Grammars (DCGs): Internally, Trealla maps the file contents directly to memory with mmap(2), an innovation that is currently unique to Trealla! There is also a recent WASM embedding: https://github.com/guregu/trealla-go Thank you a lot Andre
Read the rest
w and all contributors for your great work on Trealla! It is to be hoped that these implementation techniques are also adopted in other Prolog systems!
In Trealla – A compact, efficient Prolog interpreter written in plain-old C
I 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/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.
In Trealla Prolog embedded in Go using WASM

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.