Earlier quoted context omitted.
I always thought that pattern matching would be an excellent feature for other programming languages, but it seems that it hasn't become popular. Many strategies available to Prolog could become possible just by the addition of this feature. One possible implementation of the idea occurs with C++ templates specialized with numerical parameters. It also seems that Mathematica provides pattern matching, but I don't use…
Erlang, Elixir, Swift, Rust, Python, probably some others. That list is roughly in order of how capable and useful the pattern matching is in each of those languages. Erlang was originally written in Prolog. Also, I definitely agree it's a feature I miss everywhere when not using Erlang/Elixir.
I'm not mutable, I'm partially instantiated
61–70 of 77 posts
Re: I'm not mutable, I'm partially instantiated
#62Earlier quoted context omitted.
Erlang, Elixir, Swift, Rust, Python, probably some others. That list is roughly in order of how capable and useful the pattern matching is in each of those languages. Erlang was originally written in Prolog. Also, I definitely agree it's a feature I miss everywhere when not using Erlang/Elixir.
I'm curious, how does Swift have better pattern matching than Rust?
Re: I'm not mutable, I'm partially instantiated
#63I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…
Do you have a suggestion on where to / how to start learning Prolog beyond towers-of-hanoi? Prolog is basically the last language on my list of things I want to look at, but whenever I tried, I failed to find anything practical to do/try.
It starts out pretty easy but gets harder and requires more thought. It has different sections on things like list processing or graph problems.
Re: I'm not mutable, I'm partially instantiated
#64Earlier quoted context omitted.
It doesn't scale that well because integers are their own, opaque thing in Prolog, and the is predicate is unidirectional. However, there's no inherent reason this has to be the case: you can construct your own representation of the integers from the Peano axioms, and recover bidirectionality of addition. (You'll want to be using some typed variant of Prolog with the "unary tree of units" optimisation, otherwise inte…
Modern Prolog libraries have handled the issues of unidirectional integer predicates, so the old ways of handling numeric values is not relevant for most problems.
On the other hand CLP(FD) is not new at all (it is very popular for constraint programming).
Re: I'm not mutable, I'm partially instantiated
#65Earlier quoted context omitted.
Matching of patterns , with only a single occurrence allowed for each variable, is fairly popular in languages designed in the last two decades, isn’t it? A lot of those have or at least borrow from ML heritage, and that of course places a big emphasis on algebraic types and pattern matching. Full-blown unification remains niche, that’s true, but it’s just a fairly heavyweight feature, and I don’t really know how you…
Simon Peyton Jones (of Haskell) is working on Verse, a functional relational programming language, that merges the ideas of both functional and logical programming into one. It’s being done to facilitate Fortnite metaverse, as he’s doing this work at Epic. https://youtu.be/OJv8rFap0Nw?si=OmBT9CBJIxdJE1Jv
Re: I'm not mutable, I'm partially instantiated
#66Earlier quoted context omitted.
Modern Prolog libraries have handled the issues of unidirectional integer predicates, so the old ways of handling numeric values is not relevant for most problems.
Many times the algorithm that you are implementing requires a precise data flow that is not reversible, so using traditional arithmetic (is/2) is better for catching errors. On the other hand CLP(FD) is not new at all (it is very popular for constraint programming).
Re: I'm not mutable, I'm partially instantiated
#67Is "The Art of Prolog" a good place to start with the lanugage?
Honestly, the language is super small. Best way to learn IMO is to go on https://swish.swi-prolog.org/ and do the examples / play with it. If you stick to it, then you can branch to other engines later (there are many systems with unique features).
Re: I'm not mutable, I'm partially instantiated
#68I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…
Re: I'm not mutable, I'm partially instantiated
#69Partially instantiated data structures are also available in Haskell (via Laziness), in OCaml (via tail modulo cons, https://inria.hal.science/hal-03146495/document ) and Koka (via constructor contexts, https://dl.acm.org/doi/pdf/10.1145/3656398 )