Live data from Hacker News

Why Learn Prolog in 2021?

dstrohmaier.com

151–160 of 171 posts

Re: Why Learn Prolog in 2021?

#151
post #64

Earlier quoted context omitted.

+1 to Datalog -- it is fantastic for static analysis in particular! There are a bunch of papers from Yannis Smaragdakis' group on this; I built my thesis work on top of their system Doop [1] which is a whole-program points-to analysis written completely in Datalog. In general it's very nice to be able to prototype queries/inference rules quickly and then tweak clause ordering, etc for performance later if needed. [1]…

Probably worth mentioning for those interested in Datalog that there's actually a growing selection of databases for Clojure that use Datalog as their query language. These Clojure variants of Datalog (they model triples as Clojure data structures) are basically becoming as ubiquitous in Clojure as SQL is elsewhere. I have documented them here: https://github.com/simongray/clojure-graph-resources#datalog

If I may hijack the Clojure reference, how does Clojure’s core/logic compare to Prolog? Do they broadly fit in the same problem space?

Re: Why Learn Prolog in 2021?

#152
post #14

How do you guys think about the opportunity cost of learning dead/dying/new/unpopular languages? Even with newer languages that are gaining popularity and are likely to be used in the future, I struggle to justify the time investment. I could be wrong but some of my concerns are: - my time is better spent getting deeper into some more popular language that I already know to some extent - unused skills deteriorate wit…

If all you see with languages is the dollars you can make with an hour of time then learn whatever the next COBOL, C#, Java or Python. If you are focusing on solving problems, then learning another language, especially one that allows you to approach problems differently makes a lot of sense. I haven't used Prolog in anger in about 20 years. But the experience with declarative, logic programming has carried over to nearly everything I've done (you'll see state machines differently and see other logic patterns you can generalize). The resume isn't the be-all end all. Programming is a portfolio profession. You can prove your skill by showing your work - even if it's just some toy you wrote for fun on the weekend.

Re: Why Learn Prolog in 2021?

#153

Earlier quoted context omitted.

Probably worth mentioning for those interested in Datalog that there's actually a growing selection of databases for Clojure that use Datalog as their query language. These Clojure variants of Datalog (they model triples as Clojure data structures) are basically becoming as ubiquitous in Clojure as SQL is elsewhere. I have documented them here: https://github.com/simongray/clojure-graph-resources#datalog

If I may hijack the Clojure reference, how does Clojure’s core/logic compare to Prolog? Do they broadly fit in the same problem space?

I think core.logic is basically just a Clojure implementation of miniKanren. I'm not too familiar with logic programming myself, but my impression is that miniKanren, core.logic, and Prolog all use basically the same algorithm, operate on the same type of data, and try to solve the same set of problems. The advantages/disadvantages are probably external to the core problem space, e.g. do you prefer an embedded DSL better to a full-blown logic programming language and so on.

I'm a hardcore Clojure advocate (it's a fantastic programming language with a great ecosystem of libraries), but there's no doubt that the amount of resources available for learning the API of core.logic is less than what's available for Prolog. If the objective is to learn logic programming from the available resources, Prolog is probably the better option.

Re: Why Learn Prolog in 2021?

#154

Earlier quoted context omitted.

I did some further research and it seems like The Art of Prolog gets the most love even though it's from the mid-nineties - and still hella expensive like you say! The only thing I'm wondering about are skipping any important developments made in the last 25 years, but I guess I can always jump into the more up-to-date online resources by then.

The Art of Prolog is available as a free download (PDF) on the MIT Press website under „Open Access“. AFAIK the biggest item that’s missing is constraint logic programming. Markus Triska discusses CLP in his Power of Prolog book.

Thank you for pointing that out.

Re: Why Learn Prolog in 2021?

#155
post #91

Earlier quoted context omitted.

I worked at a Scala shop in 2011. It was pure hell. Slow compiles, bad tooling (the Scala plugin for Eclipse was a slow as molasses, IntelliJ's was a bit better though), inexperienced developers. I asked why they chose Scala... It was obviously immature at the time. "Joe thought it was good." (Joe was the architect.) I'd never touch it again.

It's changed beyond recognition since 2015 let alone 2011. Seems odd to base your judgment of it on an experience 10 years ago.

My other experiences at that company definitely put things in a bad light. I should take another look at it, you're right...

Re: Why Learn Prolog in 2021?

#156
post #14

How do you guys think about the opportunity cost of learning dead/dying/new/unpopular languages? Even with newer languages that are gaining popularity and are likely to be used in the future, I struggle to justify the time investment. I could be wrong but some of my concerns are: - my time is better spent getting deeper into some more popular language that I already know to some extent - unused skills deteriorate wit…

(speaking for myself)

I focus on why a language looks interesting and worthwhile to learn - i.e. what new ideas are in it that are worth stealing.

Over and over, I've found that grasping the new ideas in one language almost always permits you to use it in another more "mundane" language. I've for example used C++ functionally, brought Objective-C and Erlang ideas into C++ and so on when I was dominantly programming in C++. During that period, I also made a scheme-dialect interpreter in C because for some of the things we wanted to do C/C++ were too hard boiled.

More recently, I've brought CSP into Javascript through sweet.js so I can write go-routines in JS, and along the way also brought Mozart/Oz's "data flow variables" a.k.a. promises as native to JS (again through sweet.js).

I've also run a short fun "course" at my company called "no spoon" where the participants build a stack-based language in JS and implement many defining features of many other programming languages .. including all the above.

So what I'm trying to say is that you don't need to lament that you can't use a language that you learnt in your day job. New ideas in languages are always worth learning no matter what language you work with on a day-to-day basis.

Re: Why Learn Prolog in 2021?

#157

Earlier quoted context omitted.

Scala got huge because of Spark. I'm a Scala programmer due to Spark. I love it.

Indeed. The only recent Scala job's I have seen in Australia have been Spark jobs because Spark uses Scala. Even these are diapering for Python Spark roles. I've worked on a few big data projects for large companies. I have a huge dislike for them as mostly seem about how can we fuck over a customer to better the business or do shady stuff with the data rather than anything meaningful. That and it's mostly just ETL,…

>I've worked on a few big data projects for large companies. I have a huge dislike for them as mostly seem about how can we fuck over a customer to better the business or do shady stuff with the data rather than anything meaningful.

Sounds similar to the AI hype these days.

Re: Why Learn Prolog in 2021?

#158

Earlier quoted context omitted.

Learning an esoteric language is as valuable as learning anything else: it’s as challenging and as mind opening as you’re willing to stray. If you’re just exploring another language with the same paradigms you’re used to, you’re just playing in a sandbox. If you’re trying something that feels novel, that has different primitives and constructs and workflows, you might learn new ways to think about using your more com…

I get your point, but Prolog is by no means an esoteric language. It (or derivatives such as Datalog) has been the lingua franca for logic and constraint programming since about the mid-1970's, is an ISO-standardized language, and has more implementations than most programming language out there, including shells, JavaScript, BASIC (but probably not as many as historic LISP derivatives lol), has inspired the syntax o…

Yes, thank you for explaining that. I meant to add a note that Prolog isn’t esoteric too, but I was getting close to bed time so left it at what I did write for the benefit of GP’s (and others’) horizon expansion.

Re: Why Learn Prolog in 2021?

#159

Prolog implementations are too heavily reliant on the stated order of predicate rules in order to make execution progress. Many predicates are non-terminating or extremely inefficient when faced with goal inversion, but are often 'fixed' by simply reversing the order of some of its rules (but making it useless in the original direction in the process). This is disappointing when trying to maximize prolog's biggest po…

>> Many predicates are non-terminating or extremely inefficient when faced with goal inversion, but are often 'fixed' by simply reversing the order of some of its rules (but making it useless in the original direction in the process). This is disappointing when trying to maximize prolog's biggest potential: building true total relations that can project in any direction with a single definition. I don't think that's…

> I cannot easily think of an example where changing the order of clauses (not "goals") in a predicate definition prevents the program from "runnign backwards".

It's bad enough to use "directions" for what are properly called "modes", but it's positively counterproductive to say that anything in Prolog runs "backwards". Prolog always runs top-to-bottom, left-to-right, and this is precisely why it's easy to write nonterminating definitions. As a community, we are doing ourselves a disservice by claiming that anything can magically run "backwards".

As for your question, the canonical example for clause ordering being a problem is where the incorrect order prevents generation of answers because a recursive clause precedes a non-recursive one.

Example:

    xs([x | Xs]) :- xs(Xs).
    xs([]).
This recognizes lists of xs:

    ?- xs([x, x, x]).
    true.
But it cannot generate them:

    ?- xs(Xs).
    ERROR: Out of local stack
Contrast with:

    ys([]).
    ys([y | Ys]) :- ys(Ys).

    ?- ys(Ys).
    Ys = [] ;
    Ys = [y] ;
    Ys = [y, y] ;
    Ys = [y, y, y] .

Re: Why Learn Prolog in 2021?

#160

Earlier quoted context omitted.

Scala got huge because of Spark. I'm a Scala programmer due to Spark. I love it.

Indeed. The only recent Scala job's I have seen in Australia have been Spark jobs because Spark uses Scala. Even these are diapering for Python Spark roles. I've worked on a few big data projects for large companies. I have a huge dislike for them as mostly seem about how can we fuck over a customer to better the business or do shady stuff with the data rather than anything meaningful. That and it's mostly just ETL,…

Yes for us Spark is being used for just ETL. It's internal data though. It's at the scale where no single machine could ever handle it though. It's replacing large proprietary systems like mainframes and teradata.

We wrote a framework to heavily simplify writing these ETL flows. No developer of the ETL flows is using Scala unless something custom is required. I wish we could opensource it.

Post reply on HN