Live data from Hacker News

An embeddable Prolog scripting language for Go

github.com

21–30 of 36 posts

Re: An embeddable Prolog scripting language for Go

#21

Every language should come with a Prolog interpreter. :) Well done, ichiban team!

Some of them do, for type resolution. Rust has Chalk: https://github.com/rust-lang/chalk, Haskell has something that can be used too: https://aphyr.com/posts/342-typing-the-technical-interview.

Re: An embeddable Prolog scripting language for Go

#22

Every language should come with a Prolog interpreter. :) Well done, ichiban team!

I never used prolog. In my mind it is some old unused language. What is good about it and why should it be embedded into other languages?

Unification and constraint solving is a big reason why. Prolog is definitely the easiest language to write a type checker in because it not only has unification built in, it is also excellent at navigating trees like type hierarchies.

Something I've personally used it for was navigating the parse tree of some T-SQL I was analyzing (it was 100k+ LoC so manual analysis was out of the question). There is a pretty good C# library for parsing T-SQL, but it is unwieldy to use since it relies on visitors and has tons of different typed nodes with a huge inheritance hierarchy. I ended up exporting this to JSON including type information and initially used jq for analysis. However, even that ended up being hard to manage so I switched to Prolog and it was way easier to write. In terms of this project, I particularly liked that the code was so dense and expressive that I could write the program by first testing things out in the REPL.

Re: An embeddable Prolog scripting language for Go

#24
post #9

I've been keeping an eye on this to use for the rules engine in a card game I'm writing[0]. Very excited to get back into using Prolog; I think it's fallen by the wayside a bit in the last decade or two but there's some sectors that still have strong arguments for using it if not as the main language then at least an extension language. [0] Inspired by a HN comment a while back about Gleemin, the MTG expert engine in…

Have you had a look at Expr? https://github.com/antonmedv/expr

We are using it for ETL processing and are very happy with it. The performance is excellent and it is easily extendable.

Re: An embeddable Prolog scripting language for Go

#25
post #9

I've been keeping an eye on this to use for the rules engine in a card game I'm writing[0]. Very excited to get back into using Prolog; I think it's fallen by the wayside a bit in the last decade or two but there's some sectors that still have strong arguments for using it if not as the main language then at least an extension language. [0] Inspired by a HN comment a while back about Gleemin, the MTG expert engine in…

Oh, hey, that's cool! Good luck with your card game, I hope we'll get to see a "Show HN" soon (no pressure!) :)

Thanks! Your post was really inspiring to me because I'd been grappling with the issue for a while; the rules are all hardcoded in Go right now and I'd been slowly trying to migrate the engine to either Guile or (more likely, since Guile in Go is through cgo) Lua. Reading your comment reminded me that A) that's similar to how Magic Arena handles cards and B) I studied Prolog back in uni and totally could do something similar.

If something interesting comes out of it I'd love to do a Show HN but I'd probably have to work things out with my colleague first: he's the brains behind the game design and project, I'm just the code monkey :).

Re: An embeddable Prolog scripting language for Go

#26
post #9

I've been keeping an eye on this to use for the rules engine in a card game I'm writing[0]. Very excited to get back into using Prolog; I think it's fallen by the wayside a bit in the last decade or two but there's some sectors that still have strong arguments for using it if not as the main language then at least an extension language. [0] Inspired by a HN comment a while back about Gleemin, the MTG expert engine in…

I would love to hear more about this! Do you blog?

Unfortunately I don't have anything written about it now (or a blog at all), but once things get more solid and I have code I'm not embarrassed to show I'd love to do a writeup or two.

Re: An embeddable Prolog scripting language for Go

#27
post #26

Earlier quoted context omitted.

I would love to hear more about this! Do you blog?

Unfortunately I don't have anything written about it now (or a blog at all), but once things get more solid and I have code I'm not embarrassed to show I'd love to do a writeup or two.

Usually the best time to show code - and, indeed, to publish a blog post - is when you're still at least a bit embarassed by it.

I've learned over time that what I consider a barely acceptable first draft of either is often even so of great interest to other people and reminding myself that my own perfectionism is in fact mostly counterproductive. Ok, for critical code that really really needs to work reliably I let myself go full pure math grad on the problem but for everything else ... shipping is a feature.

A suggestion to try and help with this - I'll often show stuff to a couple of trusted friends first and if the result is mostly approving noises that helps a lot as leverage against my brain to get it to agree I should hit publish in spite of my reservations.

Either way, good luck, and I hope whatever else happens you have fun working on this :D

Re: An embeddable Prolog scripting language for Go

#28
post #9

I've been keeping an eye on this to use for the rules engine in a card game I'm writing[0]. Very excited to get back into using Prolog; I think it's fallen by the wayside a bit in the last decade or two but there's some sectors that still have strong arguments for using it if not as the main language then at least an extension language. [0] Inspired by a HN comment a while back about Gleemin, the MTG expert engine in…

Have you had a look at Expr? https://github.com/antonmedv/expr We are using it for ETL processing and are very happy with it. The performance is excellent and it is easily extendable.

You know, I didn't think about Expr for this project but I did futz around with it as a plugin-like system for another project of mine. I liked it well enough, but I feel like it's not quite out-of-the-box robust enough for how I'm currently designing the engine.

On the other hand, definitely something to keep in mind for the matchmaking system I'm writing along with the game, so I appreciate you bringing it up.

Re: An embeddable Prolog scripting language for Go

#29

Every language should come with a Prolog interpreter. :) Well done, ichiban team!

I never used prolog. In my mind it is some old unused language. What is good about it and why should it be embedded into other languages?

Yet another explanation: we have imperative languages, functional languages, and declarative languages. Ordered by level of abstraction. Prolog fits in the latter category, together with SQL and LINQ.
Post reply on HN