News for hackers. Stuff that matters.
Re:Adventure in Prolog Tutorial (2016) by carapace on Sunday August 25, 2019 @05:42PM (#20795783)
I was exposed to Prolog about 20 years ago. A friend of mine tried to teach it to me but it didn't "click". Looking back, I'm totally puzzled by that, I cannot explain why.

Three things made me a fan:

First, Markus Triska's "The Power of Prolog" came up here on HN, and I managed to learn enough make a nice solution to the Zebra Puzzle: https://gist.github.com/calroc/603ed919bc814ccee10c1b3df6142... That got Prolog back on my radar.

Second, I had just written a type-inferencer for a stack-based language called Joy[1], and had kind of realized that what I was doing whas Prolog-shaped. So I re-implemented the interpreter and inferencer both in Prolog and discovered that they were the same code. (So I deleted one copy.) https://hg.sr.ht/~sforman/Thun/browse/default/thun/thun.pl#L...

Joy-in-Prolog is ridiculously elegant. It's almost perverse.

And then you can do messed-up things like partial evaluation: https://hg.sr.ht/~sforman/Thun/browse/default/thun/gnu-prolo...

Then, third, "Logic Programming and Compiler Writing" by David Warren went by here on HN, almost exactly a year ago https://news.ycombinator.com/item?id=17674859 (It's a 404 now but you can find it elsewhere.) I found out that there's a wealth of research to draw on, and that it's really easy to make compilers and other tools in Prolog.

It's so easy that, if you have to write a compiler from scratch it would be faster to learn Prolog and then use it to write your compiler than to (learn to) write a compiler in an imperative language you already knew!

I was already interested in compiling Joy, and here was a short, broad path to the metal. (Here's my crude and incomplete first attempt: https://hg.sr.ht/~sforman/Thun/browse/default/thun/compiler.... )

Taken all together, I realized that something like half of my professional career was wasted simply due to ignoring Prolog for twenty years, and that everything I want to do going forward is both faster and easier in Prolog. (I have embedded Joy in it and can compile it...)

[1] I wrote it up, "The Blissful Elegance of Typing Joy" http://joypy.osdn.io/notebooks/Types.html

Re:Adventure in Prolog Tutorial (2016) by richard_shelton on Sunday August 25, 2019 @06:43PM (#20796098)
About Warren's article. I just returned it back, sorry for the inconvenience :) By the way, you may find basically the same description of the compiler in The Art of Prolog book.
Re:Adventure in Prolog Tutorial (2016) by carapace on Sunday August 25, 2019 @06:51PM (#20796148)
Cheers!

It's funny, I picked up a copy of The Art of Prolog for a dollar at a library sale a couple of years earlier, and had even skimmed the ToC, but somehow the penny dropped only when I saw that paper. D'oh!

Re:Adventure in Prolog Tutorial (2016) by 6thaccount2 on Sunday August 25, 2019 @11:00PM (#20797143)
I see a lot of Python and not Prolog.
Re:Adventure in Prolog Tutorial (2016) by carapace on Monday August 26, 2019 @12:18AM (#20797435)
all the Prolog code is under ./thun

https://hg.sr.ht/~sforman/Thun/browse/default/thun