3 ms·
I've truly enjoyed all the Prolog videos on your channel[0]. I had to program a timetabling system where each event had a specific set of requirements, and you
by hjek 7y ago
I've truly enjoyed all the Prolog videos on your channel[0].
I had to program a timetabling system where each event had a specific set of requirements, and your article and video about solving sudokus and the n-queens helped me grasp the problem.
I have only been using Prolog for a month, but I could not go back to Lisp now (at least not without MiniKanren). There's still plenty of stuff I don't understand about Prolog, but it feels very expressive and powerful even with just a superficial understanding of the language.
Thank you so much for your work! Your teaching materials are very accessible for beginners. Hope you will one day make a video about DCGs (Definite Clause Grammars). I wonder if reading Noam Chomsky will help my understanding of them?
Since we are on Hacker News, I think it's interesting to look at PG's experience with Prolog, which unfortunately hasn't been as rewarding as mine:
> There are features, most notably Prolog-style pattern-matching, that seem to promise great savings in length, but turn out only to be useful for writing a few basic sequence operations like append, remove, and so on. Prolog is a great language for writing append; after that it's all downhill.[1]
> A way of expressing programs that was more abstract, but made your programs longer, would not be very enticing. (This is not just a hypothetical example. It happens in Prolog.)[2]
From watching your videos, it's easy to see how concise Prolog programs are though. I find that my own Prolog programs also tend to be extremely brief (compared to Lisp or SQL).
[0]: https://invidio.us/channel/UCFFeNyzCEQDS4KCecugmotg https://invidio.us/channel/UCFFeNyzCEQDS4KCecugmotg
[1]: http://www.paulgraham.com/arcchallenge.html http://www.paulgraham.com/arcchallenge.html
[2]: http://www.paulgraham.com/arcll1.html http://www.paulgraham.com/arcll1.html
- triska 7y agoThank you very much for your kind words! I greatly appreciate your feedback, and I am very glad that you benefit from the videos! Also, I would like to take this opportunity to thank you all collectively for your thoughtful participation in this thread, your comments and endorsements. Your feedback, encouragement and insights are making this work especially worthwhile!
- abecedarius 7y ago> more abstract, but made your programs longer There are a few main reasons for Prolog code to come out longer than Lisp: - Prolog style is mostly first order -- there's not a direct equivalent of lambda. - Mutation is also used less. - There's an equivalent of Lisp macros, but it's also less common. - You don't nest function calls, but pass common named arguments instead. So I can see where he was coming from. On the other hand I'd guess he had his Prolog experience before constraint logic programming was well supported, and certainly before MiniKanren which gives back the conveniences of Lisp and helps you take the pure-declarative subset further.
- hjek 7y agoPG does indeed use a lot of mutation in his Arc code. "Karma" on `vote-for` on HN is just incremented like this: (++ (karma i!by) (case dir up 1 down -1)) At first this looks nice and simple, but when you have to write `unvote`, you're in trouble (because not all votes increase karma, and you'll have to figure out whether the particular vote being unvoted did). I was reading through The Reasoned Schemer (which covers MiniKanren). They do a lot of unnesting when translating from functional to logical programming. And yes, this does introduce an additional variable each time, making the logical version slightly longer. Apart from the `markdown` in the Hacker News code, there is an `unmarkdown` function[0] (whose job is to translate back from HTML to markdown!). In Prolog you could have gotten away with one predicate for that. That's a 50% saving just there. And you could perhaps use DCGs to cut it down further. Not sure I about Prolog being mostly first order. Plenty of built-in predicates that take predicate arguments, like `maplist`, `findall` and `foldl` that seem to be as commonly used as in Lisp. You might be right about lambdas missing though, so not sure you can emit a predicate (although you could emit the name of a predicate and call it). I'm too new to Prolog to tell, really. [0]: https://github.com/arclanguage/anarki/blob/master/lib/markdown.arc#L120 https://github.com/arclanguage/anarki/blob/master/lib/markdo...
- abecedarius 7y agoRe: lambda expressions, it turns out there was a proposal to add them. Maybe it or something like it is in common use by now; I wouldn't know. http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/ISO-Hiord.html http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/ISO-Hi... (It's true that you can write higher-order programs without them. The style was often clumsier and used less, at least as I saw it back when I read much Prolog.) Re: unnesting, I've toyed with the idea of a slightly fancier Prolog syntax that lets you write nested calls which get desugared to the use of an extra parameter. Of course they'd have to look distinct from functors as data.