6 ms·
The Art of Prolog (1994)
- metafunctor 6y agoMy favorite quote from the book: In Prolog programming (in contrast, perhaps, to life in general) our goal is to fail as quickly as possible.
- johnisgood 6y agoAnd for people who may not have known: the initial version of Erlang was implemented in Prolog, and the let-it-crash philosophy is central to Erlang.
- im_down_w_otp 6y agoWhile both of the statements you made are true, the "let-it-crash" philosophy of Erlang seem quite orthogonal to the "fail-fast" of Prolog. "Let-it-crash" had to do with the idea that a wobbling process/service is harder to design around than one that's just definitively dead and also that most non-systematic errors in running programs are "Heisenbugs" (the problem is transient) and restarting the process/service will make it go away. In Prolog the point of "fail-fast" is to determine as quickly as possible if some search branch can't possibly provide a True result, so that you don't spend unbounded time searching for every possible version of false.
- sitkack 6y agoI think these philosophies are complementary, I could easily see one being the inspiration for the other, just are there are analogs between guard expressions and pattern matching with logical predicates. Ideas are contagious.
- jlarocco 6y agoJust to add a bit to that, since not many people know this part... Joe Armstrong and S.R. Virding wrote a case study chapter for the book, "Strand: New Concepts in Parallel Programming," and it has a section explaining the history of Erlang up to 1990. The first Erlang prototype, written in Prolog, ran into performance problems with backtracking and emulated concurrency, so it was ported to a Parlog system (a parallel Prolog) written by S.R. Virding. The Parlog implementation was still too slow, so a third implementation was created that compiled Erlang into Strand88, a commercial product from Strand Software Technologies, Inc. which claimed to be the first commercial parallel logic programming language. That implementation was finally fast enough that Erlang could be used outside of the Computer Science Lab at Ericson. Presumably at some point after that it was re-written at least one more time...
- dang 6y agoSee also: 2018 https://news.ycombinator.com/item?id=18188003 https://news.ycombinator.com/item?id=18188003
- deleted 6y ago[deleted]
- nextos 6y agoIt should be noted that under the open access tab one can download the book. Aside from being one of my favorite programming books ever, and on par with SICP and PAIP I think, the font they used is really beautiful [1]. The PDF perhaps does not do it justice. On paper it's really crisp and pleasant to read. I hope MIT Press opens up The Craft of Prolog [2] too, a fantastic sequel to The Art of Prolog. [1] https://docs.microsoft.com/en-us/typography/font-list/lucida-bright https://docs.microsoft.com/en-us/typography/font-list/lucida... [2] https://mitpress.mit.edu/books/craft-prolog https://mitpress.mit.edu/books/craft-prolog
- jml7c5 6y agoIt looks like the PDF is a 1-bit scan, so the text is a bit wobbly. Though I concur that Lucida Bright is lovely. I wonder if the MIT Press — or the author — has the source files (presumably LaTeX) somewhere. It would be a shame to have a low-quality scan as the "definitive" archived version.
- deleted 6y ago[deleted]
- imglorp 6y agoThe flyleaf (first ed, 3rd printing, 1986) says This book was set in TeX by Sarah Fliegelmann at the Weizmann Institute of Science and printed and bound by MIT Press That might be another lead.
- transfire 6y agoI couldn't find it under Open Access. It's unfortunate. At a $104 I can't afford to buy. But I would love to read -- I would gladly pay $20 or so for an ebook.
- tzot 6y agoDon't try to locate it in “Open Access” at the top. Look the page in a desktop browser. Directly below the book's cover, there's a “Resources”. To the right of that “Resources”, there are “Overview”, “Author(s)”, “Open Access”; and that “Open Access” is the one you want.
- mark_l_watson 6y agoI gave away most of my technical books a few years ago, but I kept The Art if Prolog and about 50 other classics. It has been a while since I worked with Prolog professionally, but the memories are fond/good. Good to see that the PDF is available for download. For people who craft their code in languages like Python, Java, JavaScript, etc., I recommend just playing with an alternative language, whether it be Scheme, Common Lisp, Prolog, Haskell, ML, etc. Sometimes just a few evenings working through tutorials on the web is enough to expand the brain.
- Kototama 6y agoHow did you decided that it was time to give away your technical books?
- inetsee 6y ago(I'm not Mark) but I would expect it was an issue of space. About 6 years ago my wife and I moved from a house with a full basement to a condo. The house had 1200 sq feet, and the basement added another 1200 sq feet. The condo had 1400 sq feet. I had to get rid of about 1000 books and my wife had to get rid of more than 2000 books. I'm OK with ebooks (I actually prefer them), but my wife loves the feel of a real, physical book in her hands. Because of Covid-19 she has been reading more ebooks, but as soon as the library opened back up (with limitations) she went back to requesting as many books as she could.
- mark_l_watson 6y agoAs inetsee said, it is because of space. I got rid of a whole wall of shelves in my home office to make room for a meditation area and room to have my instruments out and handy.
- 7thaccount 6y agoInstruments?
- 6y ago
- sktrdie 6y agoI don't know prolog at all. Does anybody have a TLDR to what its pros & cons are and why it isn't mainstream?
- mac01021 6y agoWhile turing complete, it is essentially a DSL for doing logical deductions in a system of predicate logic. This makes it quite natural for certain classes of search and constraint satisfaction problems, but less natural for day-to-day procedural programming. Further more, it is missing many things that you come to expect in a modern programming language - arrays, good numerical performance, etc. The way it works though allows you to do some things quite beautifully. For example, since every function you right can be run either forwards or backwards (solving for any one unknown amongst the arguments or result), you can often write one single piece of logic for parsing that can just be run in reverse to do serialization (or vice versa). The main reason, though, that it (or it's progeny like Mercury) is not mainstream is really the same as the reason that Haskell and its derivatives are not. It's just too different from the more widely known algol/simula langages, and the library ecosystem is comparatively poor.
- YeGoblynQueenne 6y ago>> Further more, it is missing many things that you come to expect in a modern programming language - arrays, good numerical performance, etc. Those depend on the interpreter. For example, Gnu Prolog has full support for arrays. Swi-Prolog has good support for rational numbers. Constraint libraries like library(clpfd) in Swi-Prolog simplify numerical computations. etc. About numerical support in particular, the problem is that representing arithmetic in first order logic is not straightforward because it doesn't have a concept of a "number"- so what a "number" is, must be defined before arithmetic can be done (and in fact, to some extent, this was the purpose of FOL in the first place). Additionally, Prolog slightly departs from first order logic semantics in that it doesn't have a clearly defined concept of "function" (by contrast in FOL "arguments" of predicates are variables, constants or functions). Instead, Prolog "cheats" and allows predicates to be passed as arguments to predicates. However, for performing arithmetic operations, Prolog defines a predicate is/2 that takes as arguments two "mathematical expressions", where an expression is either a number ...or a function (so a function; because constants are functions with 0 arguments). For example, to add two numbers you would write: ?- A is 1 + 1. A = 2. This is clunky and messy and ends up hurting the eyes and the brain, even though there's no real problem with performance in particular (in most Prolog systems there's a low-level back-end that handles that anyway). The constraint library clpfd that I mention above exists to smooth out this impedance mismatch between the declarative paradigm and the wonky "functions in a language without functions" of mainline Prolog. It's billed as "declarative integer arithmetic" (and does the job well) (once you get used to it). Anyway it's not that there's no good support for numerical computations. It's just ...weird. Even in the context of, you know, Prolog.
- throwaway2380 6y agoI've been trying to push myself to learn Prolog, using this book, because Prolog seems like a very elegant way of modeling the interactions between business rules, compared to the bespoke functions I typically write during web app jobs. I have no complaints about the book, but I've been struggling to figure out an easy setup for "Prolog as a web app backend." Typical Prolog implementations are not designed to be used as concurrently-accessed databases. Datalog seems to be a nearby technology that is more pointed towards that use case, but even then, there seem to be scant few implementations of Datalog databases with transaction support, and near zero that are open source. RDF/OWL databases seem to be another conceptually-near possibility, but they also seem to have few implementations that are prepared for high-scale concurrent access. Overall, it seems that there is a decent amount of interest in "logic-type" query languages as a curiosity, but little attention to implementations that support use in OLTP business applications, which makes adoption difficult. Does anybody have any advice?
- 7532yahoogmail 6y agoAgree - rules engines are legion in commercial envs and a decent language or accessible non Java reit engine is something on my shopping list too.
- jlarocco 6y agoI'm also curious about this, and what "real world" Prolog actually look like. On one hand, I think the paradigm really simplifies some things, but then on the other hand, everything else (aka routine programming tasks) seems much more convoluted and awkward. I think PAIP may have been on to something, embedding Prolog in Lisp, but that's less elegant and more difficult in most other languages.
- pbh101 6y agoI recently participated in an online Prolog class by Anne Ogborn. It utilized SWI-Prolog [2] and SWISH [3], and mentioned Pengines [4] for web. I haven't used it personally, but that is the pointer I have for Prolog + web. [1] https://twitter.com/AnnieTheObscure https://twitter.com/AnnieTheObscure [2] https://www.swi-prolog.org/ https://www.swi-prolog.org/ [3] https://swish.swi-prolog.org/ https://swish.swi-prolog.org/ [4] https://pengines.swi-prolog.org/docs/index.html https://pengines.swi-prolog.org/docs/index.html [5] http://pathwayslms.com/swipltuts/ http://pathwayslms.com/swipltuts/ [6] https://www.youtube.com/watch?v=JmOHV5IlPyU https://www.youtube.com/watch?v=JmOHV5IlPyU
- hagmonk 6y agoDEBORDEMENT DE PILE
- anthk 6y agoNo, stack overflow is in the other tab.
- rudolph9 6y agoSomewhat related is Curry https://www-ps.informatik.uni-kiel.de/currywiki/ https://www-ps.informatik.uni-kiel.de/currywiki/ It builds off the concepts of prolog in a purely functional strongly typed way. The main compiler, PAKCS, actually targets prolog. Hard to wrap your head around without knowledge of Haskell but with taking a look at.
- transfire 6y agoI will have to read this, should I fine the time. I learned Prolog in High School, it was a challenge at first -- I didn't get it right away. But when I did I was amazed. Yet I have an ongoing problem with Prolog that I have never fully put my finger on exactly -- it's something about how side-effects intermix with pure logic. I find it makes the flow of activity hard to follow. Can anyone else relate to this and perhaps explain it better?
- tom_mellior 6y agoDo you mean side effects in the sense of I/O, or updating the database, or do you mean the binding of logic variables?
- xvilka 6y agoIf anyone is interested in learning Prolog I can recommend two very good Prolog books: The Power of Prolog (from the author of the video)[1] and Simply Logical: Intelligent Reasoning by Example[2]. I also recommend visiting the Awesome Prolog list[3]. Worth checking also interesting extension of the Prolog - Probabilistic Prolog, aka ProbLog[4]. And modern ISO-compatible implementation in Rust language - Scryer Prolog[5]. [1] https://www.metalevel.at/prolog https://www.metalevel.at/prolog [2] https://book.simply-logical.space/ https://book.simply-logical.space/ [3] https://github.com/klaussinani/awesome-prolog https://github.com/klaussinani/awesome-prolog [4] https://github.com/ML-KULeuven/problog https://github.com/ML-KULeuven/problog [5] https://github.com/mthom/scryer-prolog https://github.com/mthom/scryer-prolog
- sosilkj 6y agoI've got a few books like this now on my to-read list (SICP, etc). But in a profession that revolves around getting jira tickets into the Done column while my boss hovers over me with a stopwatch (so to speak), and then cramming leetcode for interviews when it's time to hop from one shitshow for the next ... I've come to the sad conclusion that, in this season of in my life, I just can't justify spending the additional time on such books. These books might make me "a better programmer" for some amorphous, platonic definition thereof, but in the year 2020 will these actually help me to materially progress career-wise?
- guenthert 6y agoCan't speak about the Prolog books, but SICP helped me to learn (and to some degree understand) LISP. That in turn made it easier for me to learn other languages or certain concepts of other languages. Sure, you can learn French and grammar in general without knowing Latin and most do, but it sure is easier if you do.
- daviddaviddavid 6y agoI can sympathize with this perspective. One strategy that I try to employ is to find books which are both small and good. In the case of Prolog, Clocksin and Mellish's "Programming in Prolog" falls in that category. The Art of Prolog is a great book but it's a big book and you could probably spin your wheels on it for years, whereas a smaller book can conceivably be digested even if you have a crazy day job and kids and non-programming hobbies, etc. Regarding just how it might make one a better programmer (while intentionally not answering anything about how it can "materially progress" one's career), I think that learning Prolog can make one a better problem solver because it forces you to specify the solutions to problems in terms of their truth conditions. This, in turn, makes you more likely to tackle problems by constructing mini proofs. I find this to be valuable no matter the language or language family I happen to be working in and it's a habit I definitely learned from writing Prolog.
- YeGoblynQueenne 6y agoI doubt that reading a few books will help you materially progress career-wise. From my personal experience, my interest in Prolog has absolutely shaped my carreer, but not because I read a few books (or more). Rather, because it got me interested in computer science as a subject in its own right. So here's my personal experience. I first learned about Prolog in a second year CS course at uni. I got hooked, much like other folks get hooked on Lisp and Haskell etc. I stopped saying things like "nobody uses Prolog in the gaming industry", like my classmates, and started asking questions like "wait, if facts and rules are predicates, then what are queries? [1]". So I started reading every textbook on the language that I could find in the university library. Most of them were AI textbooks also, from the time when AI was basically hand-crafted programs written in Lisp and Prolog. From that I got interested in AI, in general and -after working for a few years in the industry- I started an MSc course on AI. My MSc course was almost exclusively about statistical machine learning (I was told they were planning to rename it to "data science"). I started the course (part-time, while working) in 2014, right around the time when machine learning started becoming a hot issue; a rather fortunate state of affairs. I didn't go back to the industry with my hot new skillz though. Instead I started a PhD on Inductive Logic Programming, which is basically machine learning of logic programs, a subject that perfectly fits my background (in logic programming and machine learning). And that's where I am now- I'm in my final year and waiting to hear from the editors of the Machine Learning Journal about my submitted paper that describes a polynomial time ILP algorithm (exponentially growing hypothesis spaces are a bitch, but you can avoid them with One Simple Trick). We'll see how that goes- one does not simply publish to the MLJ. But if I get that publication it will be a major step forward to getting my thesis accepted. Er. Once I've actually written it. Anyway, morale of the story: don't just read a bunch of books. Find a deep interest in computer science instead. For me, my undergraduate wonderment at Prolog led me down the path of becoming a computer scientist, growing my knowledge and honing my skills. There's no way you can go wrong with that. (I forgot to mention I'm doing my PhD at one of the top rated universities for engineering research; not bad for someone who started as an unskilled immigrant working at a warehouse :) _________________ [1] Also predicates. Mind blown.