←back to thread

Learn Prolog Now

(lpn.swi-prolog.org)
207 points rramadass | 3 comments | | HN request time: 0.614s | source
Show context
ux266478 ◴[] No.45902197[source]
Prolog really is such a fantastic system, if I can justify its usage then I won't hesitate to do so. Most of the time I'll call a language that I find to be powerful a "power tool", but that doesn't apply here. Prolog is beyond a power tool. A one-off bit of experimental tech built by the greatest minds of a forgotten generation. You'd it find deep in irradiated ruins of a dead city, buried far underground in a bunker easily missed. A supercomputer with the REPL's cursor flickering away in monochrome phosphor. It's sitting there, forgotten. Dutifully waiting for you to jack in.
replies(1): >>45902700 #
1. lmf4lol ◴[] No.45902700[source]
When I entered university for my Bachelors, I was 28 years old and already worked for 5 or 6 years as a self-taught programmer in the industry. In the first semester, we had a Logic Programming class and it was solely taught in Prolog. At first, I was mega overwhelmed. It was so different than anything I did before and I had to unlearn a lot of things that I was used to in "regular" programming. At the end of the class, I was a convert! It also opened up my mind to functional programming and mathematical/logical thinking in general.

I still think that Prolog should be mandatory for every programmer. It opens up the mind in such a logical way... Love it.

Unfortunately, I never found an opportunity in my 11 years since then to use it in my professional practice. Or maybe I just missed the opportunities?????

replies(1): >>45903064 #
2. ux266478 ◴[] No.45903064[source]
Did they teach you how to use DCGs? A few months ago I used EDCGs as part of a de-spaghettification and bug fixing effort to trawl a really nasty 10k loc sepples compilation unit and generate tags for different parts of it. Think ending up with a couple thousand ground terms like:

tag(TypeOfTag, ParentFunction, Line).

Type of tag indicating things like an unnecessary function call, unidiomatic conditional, etc.

I then used the REPL to pull things apart, wrote some manual notes, and then consulted my complete knowledgebase to create an action plan. Pretty classical expert system stuff. Originally I was expecting the bug fixing effort to take a couple of months. 10 days of Prolog code + 2 days of Prolog interaction + 3 days of sepples weedwacking and adjusting the what remained in the plugboard.

replies(1): >>45904553 #
3. cpill ◴[] No.45904553[source]
This sounds interesting. Perhaps you could write a blog post about it? I'm always looking for use cases for Prolog