Live data from Hacker News

The Power of Prolog

metalevel.at

11–20 of 164 posts

Re: The Power of Prolog

#11
post #3

One of the nicest examples of the power of prolog is that Windows NT contained a prolog implementation to take care of network configuration, replacing the previous codebase: http://www.redditmirror.cc/cache/websites/web.archive.org_84...

My one regret in a project at work (internal tool) was that I didn't persuade management to let me use an embedded prolog in the application. Instead I rewrote half of Prolog (badly) in C#.

I don't get it. Isn't that the same thing but worse?

Edit: Also, Greenspun's Tenth Rule of Programming:

Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

Re: The Power of Prolog

#13
post #11

Earlier quoted context omitted.

My one regret in a project at work (internal tool) was that I didn't persuade management to let me use an embedded prolog in the application. Instead I rewrote half of Prolog (badly) in C#.

I don't get it. Isn't that the same thing but worse? Edit: Also, Greenspun's Tenth Rule of Programming: Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

It was worse. That office had an aversion to anything not-Microsoft for dev tools unless they were for the embedded systems we maintained. They also had an aversion to any language that wasn't "industry standard", whatever that meant (because, clearly, prolog and others do have industry standards associated with them; here they meant commonly used and easy to hire for).

Re: The Power of Prolog

#14
post #3

One of the nicest examples of the power of prolog is that Windows NT contained a prolog implementation to take care of network configuration, replacing the previous codebase: http://www.redditmirror.cc/cache/websites/web.archive.org_84...

My one regret in a project at work (internal tool) was that I didn't persuade management to let me use an embedded prolog in the application. Instead I rewrote half of Prolog (badly) in C#.

Why couldn't you just tell them you were going to have to rewrite it if you couldnt get it embedded?

Re: The Power of Prolog

#15

Earlier quoted context omitted.

My one regret in a project at work (internal tool) was that I didn't persuade management to let me use an embedded prolog in the application. Instead I rewrote half of Prolog (badly) in C#.

Why couldn't you just tell them you were going to have to rewrite it if you couldnt get it embedded?

It wasn't already written in prolog. It just would've been much easier and more straightforward for that particular application to write the business logic side in prolog. From a UI standpoint, I've never used prolog for a GUI so it would've needed to be embedded in something else (likely C# given the office preference) anyways, so the decision was to put everything in C# and skip my prolog idea. If I still had those notes, I basically translated handwritten prolog-esque code into C# anyways.

EDIT: In very corporate offices like that one, you don't get to use unless it's staying strictly internal (this one had the potential to be released to customers), you have low oversight and can get away with it (not my case), you have a history of choosing wisely (I had little history with them at that point). They prefer to minimize the risk on the maintenance end (NB: doesn't mean they do what's needed to make maintainable code, they do what's needed to make it easy to hire maintainers by sticking to popular languages and frameworks instead).

Re: The Power of Prolog

#16
The power: require a rethink of approaches to programming The failure: the claim by such folk that all compute problems are best solved by prolog/clojure/related even when such a domain specific language is not pertinent.

Re: The Power of Prolog

#18
post #5

erlang syntax is prolog inspired, not sure if that's a good thing though :)

The prologesque syntax gets a lot of grief, but I genuinely appreciate it. I like my different paradigm languages to look different, helps me think differently.

(but it's much closer to Algol than Lisp is, so I don't have to bend my brain quite that hard)

Re: The Power of Prolog

#19
i have always trouble understaing prolog, lot of guide online seem to just tackle the syntax or assume you already know a lot of logic programming, for example the first example in the link (https://www.metalevel.at/prolog/facets):

        list_length([], 0).
        list_length([_|Ls], N) :-
                N #> 0,
                N #= N0 + 1,
                list_length(Ls, N0).
i don't undestand it, i read the segment describing it multiple time but i still don't get it, and is not the syntax i don't undestand how it should work, a tried reading the next few chapter but i feel i'm missing something! is there a "prolog for dummies" out there?

Re: The Power of Prolog

#20
post #2

Roughly half the 'power of prolog' comes from the 'power of logic programming' and prolog is by far not the only logic programming language, e.g., - You can do logic programming using minikanren in scheme. (you can also extend the minikanren system if you find a feature missing). - Minikanren was implemented in clojure and called core.logic. - It was also ported to python by Matthew Rocklin I think, called logpy. - T…

Not really. I use SWI Prolog for a lot of personal projects (that actually see QPS no less) and there's a lot more to it than that. SWI gives you: good debugging support (with trace and spy), hooks into the Prolog database (with asserta/z and retract), optimized implementations of difference lists, online help, and so much more. Don't even get me started on its amazing DCG support that makes Regex feel like a Neolithic toy. Not only that but Prolog's Syntax gives you very similar properties to lisp's homoiconicity (first class atoms, metaprogramming, etc). Sure you can reimplement all of this in miniKanren, but it's all there waiting for you in SWI Prolog already! There's a lot more to a language than just its concepts.

Every time I hack in Prolog I always feel like I'm living the idea that I "tell the computer what to do not how to do it". It's a shame that more folks don't use it.

Post reply on HN