Hacker News new | ask | show | jobs
by alhimik45 2628 days ago
Hmm, converting HTML to Pdf doesn't look like a task for logic programming language. Why did they choose Mercury?
3 comments

That's a peculiar opinion. Usually, whenever discussion comes to parsing and codecs, people like to mention how the problem P could be solved with a purely functional language L so much more elegantly. And yes, logic and purely functional languages are not the same, but they seem to be very close relatives.
I mentioned to my Haskell teacher in uni that I did 2 years of intensive Prolog for an AI course at another uni and so that I grasp the basics or ‘everything recursion’ (mind you, this is 25 years or so ago). He got angry and said the two have nothing in common and if I believe that I definitely should pay more attention. It was weird as I did not say they are alike; just that they share some concepts which are usually hard to understand for imperative programmers, but, after 2 years of breathing Prolog really are second nature.
Sibling comment is spot on. Your "teacher" was either not well informed or dealing with some issues himself.

To cathartically let go of that experience, I suggest reading up on Curry, the logical language extension to Haskell: https://en.wikipedia.org/wiki/Curry_(programming_language)

Honestly, that speaks more about the teacher's personal issues than it does about the similarities between logic and purely functional programming. I'm sorry that you had to experience that.
Waaaaaat. There's so much in Haskell's type system that is also in logic programming. Like Hindley-Milner type inference and type class instance resolution.
I work at YesLogic and answered a similar question on Lobste.rs recently: https://lobste.rs/s/7op1vm/my_first_3_weeks_professional_rus...

The gist of it (as far as I understand it) is that at the time Prince was started (around 2003?), there wasn't a declarative/functional programming language out there to use that was fast enough, or had as much interest in low level control as Mercury had. The founders were pretty convinced that this was the style of programming they wanted to do, and the creators of Mercury were locals to Melbourne, so that kind of tipped things in Mercury's favor.

In general we tend to use the functional/typed parts of the language more than the logic parts of the language (although that can be handy at times). Pretty much any form of programming can benefit from being expressed in that way. It might be that the team is so highly competent, but the Prince source is one of the best I've seen, even after all these years, and it's still reasonably easy to make changes without fear. That's mainly what we get out of Mercury.

Am not a Prince developer, but I can imagine that a logic programming language would greatly simplify some of constraint solving tasks.
Funnily enough we don't actually use the built-in non-determinism all that much. Often the layout tasks that HTML and CSS demand require us to build our own, bespoke algorithms, for performance and control reasons. We still get a bunch of leverage out of the type system and data modelling power of the language though.
That's really fascinating (& thanks for taking the time to comment).