Hacker News new | past | comments | ask | show | jobs | submit login

James, check out Mercury next as it's a faster, better Prolog with some industrial use.

https://mercurylang.org




Last time I looked (admittedly years ago), it wasn't an unambiguously "better Prolog", because Mercury's static mode system couldn't capture all of what Prolog can do with unification.


I'm repeating what most users told me. This is a new one on me. Care to elaborate?


A common Prolog programming pattern involves creating a partially instantiated term (a "structure" with "holes") and filling in the details later. This can improve expressivity, composability, and performance.

For example, this code:

    L = [_,_,_], maplist(p, L)
enumerates all three-element lists whose members satisfy the predicate p. This technique is impossible in Mercury because it does not allow terms with holes.

Of course you can still compute the same result in Mercury, but you will have to do more work: I think you would have to write a specialized predicate instead of using a higher-order predicate from the library.


Thanks for the explanation. I agree the example is concise and powerful. I'll run it by Mercury users or developers to see what their answer to that is. They might have a good solution or maybe not due to language's design.


You're welcome! I last looked at Mercury about 3 years ago, and I vaguely remember partial instantiation being documented as an eternal low-priority future feature. Maybe there's been progress... or maybe they'll say this is less useful than Prolog weenies like to claim ;-)

Out of interest, in what sort of function do you talk to Mercury users and developers if you don't use it yourself?


Oh I just bring attention to tech that people might be interested in. You're the first to mention a drawback. So, I might just ask one of them if there's a list of thing people like about Prolog hard or non-existent in Mercury. Next time I'll be better informed if anyone asks. That's all.

I do have a slight tie-in to my field where I keep logic systems in my peripheral in case they become useful for (a) executable specifications, (b) connections to provers like Milawa, (c) easier formal verification, or (d) commercial deployment in a good one that almost skips the coding phase by keeping code close to specs. Mission Critical IT claims to use Mercury for (a) and (d) with a finance developer linked here a while back using Prolog for whole app. Got easy extensions and fixes as result. So, these conversations might have benefit later.


That looks really cool. To be honest I hadn't planned to use Prolog too much beyond this project, but I'll give Mercury a try if I decide to dive deeper into logic programming. Thanks!


I read that Prince XML (now called just Prince) was written in Mercury.

https://en.wikipedia.org/wiki/Prince_(software)

It's a software to generate PDF from XML and HTML content with CSS.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: